Skip to content

Commit

Permalink
(#17) Add item template for Hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Western authored and patiqs committed Nov 2, 2021
1 parent 542a169 commit ffa9761
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# v$vNext$ - $buildDate$

* Feature: (#17) Add item template for Hooks

# v2021.0.199 - 2021-10-29

* Fix: (#14) Remove implicit convetion of DateTime.MinValue (local) to DateTimeOffset (UTC) resulting in ArgumentOutOfRangeException

# v2021.0.198 - 2021-10-15
Expand Down
34 changes: 34 additions & 0 deletions SpecFlow.VisualStudio.ItemTemplates/Hooks/Hooks1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using TechTalk.SpecFlow;

namespace $rootnamespace$
{
[Binding]
public sealed class $safeitemname$
{
// For additional details on SpecFlow hooks see http://go.specflow.org/doc-hooks

[BeforeScenario("@tag1")]
public void BeforeScenarioWithTag()
{
// Example of filtering hooks using tags. (in this case, this 'before scenario' hook will execute if the feature/scenario contains the tag '@tag1')
// See https://docs.specflow.org/projects/specflow/en/latest/Bindings/Hooks.html?highlight=hooks#tag-scoping

//TODO: implement logic that has to run before executing each scenario
}

[BeforeScenario(Order = 1)]
public void FirstBeforeScenario()
{
// Example of ordering the execution of hooks
// See https://docs.specflow.org/projects/specflow/en/latest/Bindings/Hooks.html?highlight=order#hook-execution-order

//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
}
}
}
14 changes: 14 additions & 0 deletions SpecFlow.VisualStudio.ItemTemplates/Hooks/Hooks_CSharp.vstemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>Hooks.cs</DefaultName>
<Name>SpecFlow Hooks (event bindings)</Name>
<Description>SpecFlow Hooks (event bindings)</Description>
<ProjectType>CSharp</ProjectType>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
<SortOrder>10</SortOrder>
<Icon>SpecFlowIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">Hooks1.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
14 changes: 14 additions & 0 deletions SpecFlow.VisualStudio.ItemTemplates/Hooks/Hooks_VB.vstemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>Hooks.cs</DefaultName>
<Name>SpecFlow Hooks (event bindings)</Name>
<Description>SpecFlow Hooks (event bindings)</Description>
<ProjectType>VisualBasic</ProjectType>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
<SortOrder>10</SortOrder>
<Icon>SpecFlowIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">Hooks1.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Hooks\Hooks1.cs" />
<None Include="Hooks\Hooks1.cs" />
</ItemGroup>

<ItemGroup>
<VSTemplate Include="SpecFlowConfig\SpecFlowConfig_VB.vstemplate">
<OutputSubPath>SpecFlow</OutputSubPath>
Expand All @@ -28,6 +33,12 @@
<VSTemplate Include="FeatureFile\FeatureFile_VB.vstemplate">
<OutputSubPath>SpecFlow</OutputSubPath>
</VSTemplate>
<VSTemplate Include="Hooks\Hooks_CSharp.vstemplate">
<OutputSubPath>SpecFlow</OutputSubPath>
</VSTemplate>
<VSTemplate Include="Hooks\Hooks_VB.vstemplate">
<OutputSubPath>SpecFlow</OutputSubPath>
</VSTemplate>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit ffa9761

Please sign in to comment.