Skip to content

Commit

Permalink
Went ahead and changed the file templates for Step and Event Definiti…
Browse files Browse the repository at this point in the history
…ons. I just didn't like the format of the code using the CodeDom for generation. That and the fact that I couldn't get Comments to generate. The only reasone I went with the CodeDom first, was so I didn't have to create a template for each language we want to support. Once I get the VB exception figured out, I will add the templates for it also.
  • Loading branch information
dragan committed Jun 1, 2010
1 parent 3866f22 commit 8eb3ae4
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,84 +7,95 @@
<_Name>SpecFlow Event Definition</_Name>
<Icon>res:SpecFlowEventDefinitionIcon.ico</Icon>
<_Category>NUnit</_Category>
<LanguageName>*</LanguageName>
<LanguageName>C#</LanguageName>
<_Description>Creates a SpecFlow Event Definition file.</_Description>
</TemplateConfiguration>

<!-- Template Content -->
<TemplateFiles>
<CodeDomFile>
<CompileUnit>
<Namespaces>
<Namespace Name="">
<Imports>
<NamespaceImport Namespace="System"/>
<NamespaceImport Namespace="TechTalk.SpecFlow"/>
</Imports>
</Namespace>
<Namespace Name="${Namespace}">
<Types>
<TypeDeclaration Name="${Name}" IsClass="true">
<CustomAttributes>
<AttributeDeclaration Name="Binding"/>
</CustomAttributes>
<Members>
<MemberMethod Attributes="Public, Final" Name="BeforeStep" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="BeforeStep"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="AfterStep" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="AfterStep"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="BeforeScenarioBlock" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="BeforeScenarioBlock"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="AfterScenarioBlock" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="AfterScenarioBlock"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="BeforeScenario" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="BeforeScenario"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="AfterScenario" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="AfterScenario"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="BeforeFeature" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="BeforeFeature"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="AfterFeature" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="AfterFeature"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="BeforeTestRun" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="BeforeTestRun"/>
</CustomAttributes>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="AfterTestRun" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="AfterTestRun"/>
</CustomAttributes>
</MemberMethod>
</Members>
</TypeDeclaration>
</Types>
</Namespace>
</Namespaces>
</CompileUnit>
</CodeDomFile>
<File DefaultExtension=".cs" DefaultName="SpecFlowEventDefinition1">
<![CDATA[using System;
using TechTalk.SpecFlow;
namespace ${Namespace}
{
[Binding]
public class ${Name}
{
[BeforeStep]
public void BeforeStep()
{
// TODO: implement logic that has to run before each scenario step
// For storing and retrieving scenario-specific data,
// the instance fields of the class or the
// ScenarioContext.Current
// collection can be used.
// For storing and retrieving feature-specific data, the
// FeatureContext.Current
// collection can be used.
// Use the attribute overload to specify tags. If tags are specified, the event
// handler will be executed only if any of the tags are specified for the
// feature or the scenario.
// [BeforeStep("mytag")]
}
[AfterStep]
public void AfterStep()
{
// TODO: implement logic that has to run after each scenario step
}
[BeforeScenarioBlock]
public void BeforeScenarioBlock()
{
// TODO: implement logic that has to run before each scenario block (given-when-then)
}
[AfterScenarioBlock]
public void AfterScenarioBlock()
{
// TODO: implement logic that has to run after each scenario block (given-when-then)
}
[BeforeScenario]
public void BeforeScenario()
{
// TODO: implement logic that has to run before executing each scenario
}
[AfterScenario]
public void AfterScenario()
{
// TODO: implement logic that has to run after executing each scenario
}
[BeforeFeature]
public static void BeforeFeature()
{
// TODO: implement logic that has to run before executing each feature
}
[AfterFeature]
public static void AfterFeature()
{
// TODO: implement logic that has to run after executing each feature
}
[BeforeTestRun]
public static void BeforeTestRun()
{
// TODO: implement logic that has to run before the entire test run
}
[AfterTestRun]
public static void AfterTestRun()
{
// TODO: implement logic that has to run after the entire test run
}
}
}
]]>
</File>
</TemplateFiles>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -7,112 +7,55 @@
<_Name>SpecFlow Step Definition</_Name>
<Icon>res:SpecFlowStepDefinitionIcon.ico</Icon>
<_Category>NUnit</_Category>
<LanguageName>*</LanguageName>
<LanguageName>C#</LanguageName>
<_Description>Creates a SpecFlow Step Definition file.</_Description>
</TemplateConfiguration>

<!-- Template Content -->
<TemplateFiles>
<CodeDomFile>
<CompileUnit>
<Namespaces>
<Namespace Name="">
<Imports>
<NamespaceImport Namespace="System"/>
<NamespaceImport Namespace="TechTalk.SpecFlow"/>
</Imports>
</Namespace>
<Namespace Name="${Namespace}">
<Types>
<TypeDeclaration Name="${Name}" IsClass="true">
<CustomAttributes>
<AttributeDeclaration Name="Binding"/>
</CustomAttributes>
<Members>
<MemberMethod Attributes="Public, Final" Name="GivenIHaveEnteredSomethingIntoTheCalculator" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="Given">
<Arguments>
<AttributeArgument>
<Value>
<PrimitiveExpression Value="I have entered (.*) into the calculator"/>
</Value>
</AttributeArgument>
</Arguments>
</AttributeDeclaration>
</CustomAttributes>
<Parameters>
<ParameterDeclarationExpression Type="System.Int32" Name="number"/>
</Parameters>
<Statements>
<MethodInvokeExpression>
<Method>
<MethodReferenceExpression MethodName="Pending">
<TargetObject>
<TypeReferenceExpression Type="ScenarioContext.Current"/>
</TargetObject>
</MethodReferenceExpression>
</Method>
</MethodInvokeExpression>
</Statements>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="WhenIPressAdd" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="When">
<Arguments>
<AttributeArgument>
<Value>
<PrimitiveExpression Value="I press add"/>
</Value>
</AttributeArgument>
</Arguments>
</AttributeDeclaration>
</CustomAttributes>
<Statements>
<MethodInvokeExpression>
<Method>
<MethodReferenceExpression MethodName="Pending">
<TargetObject>
<TypeReferenceExpression Type="ScenarioContext.Current"/>
</TargetObject>
</MethodReferenceExpression>
</Method>
</MethodInvokeExpression>
</Statements>
</MemberMethod>
<MemberMethod Attributes="Public, Final" Name="ThenTheResultShouldBe" ReturnType="System.Void">
<CustomAttributes>
<AttributeDeclaration Name="Then">
<Arguments>
<AttributeArgument>
<Value>
<PrimitiveExpression Value="the result should be (.*) on the screen"/>
</Value>
</AttributeArgument>
</Arguments>
</AttributeDeclaration>
</CustomAttributes>
<Parameters>
<ParameterDeclarationExpression Type="System.Int32" Name="result"/>
</Parameters>
<Statements>
<MethodInvokeExpression>
<Method>
<MethodReferenceExpression MethodName="Pending">
<TargetObject>
<TypeReferenceExpression Type="ScenarioContext.Current"/>
</TargetObject>
</MethodReferenceExpression>
</Method>
</MethodInvokeExpression>
</Statements>
</MemberMethod>
</Members>
</TypeDeclaration>
</Types>
</Namespace>
</Namespaces>
</CompileUnit>
</CodeDomFile>
<File DefaultExtension=".cs" DefaultName="SpecFlowStepDefinition1">
<![CDATA[using System;
using TechTalk.SpecFlow;
namespace ${Namespace}
{
[Binding]
public class ${Name}
{
[Given("I have entered (.*) into the calculator")]
public void GivenIHaveEnteredSomethingIntoTheCalculator(int number)
{
// TODO: implement arrange (recondition) logic
// For storing and retrieving scenario-specific data,
// the instance fields of the class or the
// ScenarioContext.Current
// collection can be used.
// To use the multiline text or the table argument of the scenario,
// additional string/Table parameters can be defined on the step definition
// method.
ScenarioContext.Current.Pending();
}
[When("I press add")]
public void WhenIPressAdd()
{
// TODO: implement act (action) logic
ScenarioContext.Current.Pending();
}
[Then("the result should be (.*) on the screen")]
public void ThenTheResultShouldBe(int result)
{
// TODO: implement assert (verification) logic
ScenarioContext.Current.Pending();
}
}
}
]]>
</File>
</TemplateFiles>
</Template>

0 comments on commit 8eb3ae4

Please sign in to comment.