diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/VerifyTestFeature.CheckIfVerifyIsWorking.verified.txt b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working with Example Tables_1.verified.txt similarity index 100% rename from Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/VerifyTestFeature.CheckIfVerifyIsWorking.verified.txt rename to Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working with Example Tables_1.verified.txt diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working with Example Tables_2.verified.txt b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working with Example Tables_2.verified.txt new file mode 100644 index 000000000..3c877c57a --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working with Example Tables_2.verified.txt @@ -0,0 +1 @@ +value \ No newline at end of file diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working.verified.txt b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working.verified.txt new file mode 100644 index 000000000..3c877c57a --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working.verified.txt @@ -0,0 +1 @@ +value \ No newline at end of file diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs index 7bfc4e63a..f90c1d5e5 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs @@ -1,42 +1,10 @@ -using System.Collections; -using TechTalk.SpecFlow; -using System.Linq; +using TechTalk.SpecFlow; namespace SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.Steps; [Binding] internal class Steps { - private readonly FeatureContext _featureContext; - private readonly ScenarioContext _scenarioContext; - - public Steps(ScenarioContext scenarioContext, FeatureContext featureContext) - { - _scenarioContext = scenarioContext; - _featureContext = featureContext; - } - - [BeforeScenario] - public void SetupVerify() - { - VerifierSettings.DerivePathInfo( - (sourceFile, projectDirectory, type, method) => - { - string scenarioInfoTitle = _scenarioContext.ScenarioInfo.Title; - - foreach (DictionaryEntry scenarioInfoArgument in _scenarioContext.ScenarioInfo.Arguments) - { - scenarioInfoTitle += "_" + scenarioInfoArgument.Value; - } - - return new PathInfo( - Path.Combine(projectDirectory, _featureContext.FeatureInfo.FolderPath), - _featureContext.FeatureInfo.Title, - scenarioInfoTitle); - }); - - } - [When("I try Verify with SpecFlow")] public async Task ITryVerifyWithSpecFlow() { diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj index e1c6b1683..8c48f69ab 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj @@ -15,6 +15,7 @@ + diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyRuntimePlugin.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyRuntimePlugin.cs new file mode 100644 index 000000000..688cba756 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyRuntimePlugin.cs @@ -0,0 +1,47 @@ +using System.Collections; +using System.IO; +using SpecFlow.Verify.SpecFlowPlugin; +using TechTalk.SpecFlow; +using TechTalk.SpecFlow.Plugins; +using TechTalk.SpecFlow.UnitTestProvider; +using VerifyTests; + +[assembly: RuntimePlugin(typeof(VerifyRuntimePlugin))] + +namespace SpecFlow.Verify.SpecFlowPlugin; + +public class VerifyRuntimePlugin : IRuntimePlugin +{ + public void Initialize(RuntimePluginEvents runtimePluginEvents, RuntimePluginParameters runtimePluginParameters, UnitTestProviderConfiguration unitTestProviderConfiguration) + { + runtimePluginEvents.CustomizeGlobalDependencies += RuntimePluginEvents_CustomizeGlobalDependencies; + } + + private void RuntimePluginEvents_CustomizeGlobalDependencies(object sender, CustomizeGlobalDependenciesEventArgs e) + { + var runtimePluginTestExecutionLifecycleEvents = e.ObjectContainer.Resolve(); + runtimePluginTestExecutionLifecycleEvents.BeforeScenario += RuntimePluginTestExecutionLifecycleEvents_BeforeScenario; + } + + private void RuntimePluginTestExecutionLifecycleEvents_BeforeScenario(object sender, RuntimePluginBeforeScenarioEventArgs e) + { + var scenarioContext = e.ObjectContainer.Resolve(); + var featureContext = e.ObjectContainer.Resolve(); + + VerifierSettings.DerivePathInfo( + (sourceFile, projectDirectory, type, method) => + { + string scenarioInfoTitle = scenarioContext.ScenarioInfo.Title; + + foreach (DictionaryEntry scenarioInfoArgument in scenarioContext.ScenarioInfo.Arguments) + { + scenarioInfoTitle += "_" + scenarioInfoArgument.Value; + } + + return new PathInfo( + Path.Combine(projectDirectory, featureContext.FeatureInfo.FolderPath), + featureContext.FeatureInfo.Title, + scenarioInfoTitle); + }); + } +}