Skip to content

Commit

Permalink
Add a new TestRunEnd extension point for plugins (#2064)
Browse files Browse the repository at this point in the history
* Embedd feature files

* Add TestRunEnd event

* Fire TestRunEnd event

* Correct RuntimePlugin documentation

* Extend changelog

* Pass only the ObjectContainer

* Adjust RuntimePlugin docs

* Update version to beta

* Raise TestRunEnd after the Hooks

- Adjust changelog
  • Loading branch information
epresi committed Jul 23, 2020
1 parent 2d63962 commit 1e60a95
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
<ItemGroup Condition="'$(UsingMicrosoftNETSdk)' != 'true'">
<Compile Include="@(SpecFlowGeneratedFiles)" Exclude="@(Compile)" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="@(SpecFlowFeatureFiles)" />
</ItemGroup>

</Target>

<Target Name="AfterUpdateFeatureFilesInProject" DependsOnTargets="IncludeCodeBehindFilesInProject">
Expand Down
4 changes: 4 additions & 0 deletions TechTalk.SpecFlow/Infrastructure/TestExecutionEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.CucumberMessages;
using TechTalk.SpecFlow.ErrorHandling;
using TechTalk.SpecFlow.Plugins;
using TechTalk.SpecFlow.Tracing;
using TechTalk.SpecFlow.UnitTestProvider;

Expand Down Expand Up @@ -146,6 +147,9 @@ public virtual void OnTestRunEnd()
}

FireEvents(HookType.AfterTestRun);

var runtimePluginEvents = TestThreadContainer.Resolve<RuntimePluginEvents>();
runtimePluginEvents.RaiseTestRunEnd(new ObjectContainer(TestThreadContainer));
}

public virtual void OnFeatureStart(FeatureInfo featureInfo)
Expand Down
9 changes: 8 additions & 1 deletion TechTalk.SpecFlow/Plugins/RuntimePluginEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,12 @@ public class CustomizeScenarioDependenciesEventArgs : ObjectContainerEventArgs
public CustomizeScenarioDependenciesEventArgs(ObjectContainer objectContainer) : base(objectContainer)
{
}
}
}

public class TestRunEndEventArgs : ObjectContainerEventArgs
{
public TestRunEndEventArgs(ObjectContainer objectContainer) : base(objectContainer)
{
}
}
}
6 changes: 6 additions & 0 deletions TechTalk.SpecFlow/Plugins/RuntimePluginEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class RuntimePluginEvents
public event EventHandler<CustomizeTestThreadDependenciesEventArgs> CustomizeTestThreadDependencies;
public event EventHandler<CustomizeFeatureDependenciesEventArgs> CustomizeFeatureDependencies;
public event EventHandler<CustomizeScenarioDependenciesEventArgs> CustomizeScenarioDependencies;
public event EventHandler<TestRunEndEventArgs> TestRunEnd;

public void RaiseRegisterGlobalDependencies(ObjectContainer objectContainer)
{
Expand Down Expand Up @@ -42,5 +43,10 @@ public void RaiseCustomizeScenarioDependencies(ObjectContainer scenarioContainer
{
CustomizeScenarioDependencies?.Invoke(this, new CustomizeScenarioDependenciesEventArgs(scenarioContainer));
}

public void RaiseTestRunEnd(ObjectContainer container)
{
TestRunEnd?.Invoke(this, new TestRunEndEventArgs(container));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<Visible>$(UsingMicrosoftNETSdk)</Visible>
</_CucumberMessagesSpecFlowFeatureFiles>

<SpecFlowFeatureFiles Include="@(_CucumberMessagesSpecFlowFeatureFiles)" />
<SpecFlowFeatureFiles Include="@(_CucumberMessagesSpecFlowFeatureFiles)" Exclude="@(SpecFlowFeatureFiles)" />
</ItemGroup>
</Target>

Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Changes after 3.3.57

Changes:
+ Add a new `TestRunEnd` extension point for plugins

Changes after 3.3.30

Changes:
Expand Down
4 changes: 2 additions & 2 deletions docs/Extend/Plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ SpecFlow loads plugins in the order they are found in the folder.
### Create a runtime plugin

1. Create a new class library for your plugin.
1. Add the SpecFlow.CustomPlugin NuGet package to your project.
1. Add the SpecFlow NuGet package to your project.
1. Define a class that implements the `IRuntimePlugin` interface (defined in TechTalk.SpecFlow.Plugins).
1. Flag your assembly with the `RuntimePlugin` attribute for the plugin to be identified by SpecFlow plugin loader. The following example demonstrates a `MyNewPlugin` class that implements the `IGeneratorPlugin` interface:
1. Flag your assembly with the `RuntimePlugin` attribute for the plugin to be identified by SpecFlow plugin loader. The following example demonstrates a `MyNewPlugin` class that implements the `IRuntimePlugin` interface:
`[assembly: RuntimePlugin(typeof(MyNewPlugin))]`
1. Implement the `Initialize` method of the `IRuntimePlugin` interface to access the `RuntimePluginEvents` and `RuntimePluginParameters`.

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "3.3",
"version": "3.3-beta",
"publicReleaseRefSpec": [
"^refs/heads/master$", // we release out of master
"^refs/tags/v\\d+\\.\\d+" // we also release tags starting with vN.N
Expand Down

0 comments on commit 1e60a95

Please sign in to comment.