From a625428b54ce7219e34e3a60e643b1e692266c3e Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Mon, 8 Aug 2022 15:39:27 +0200 Subject: [PATCH 01/10] upgrade to .NET 4.6.2 and xUnit 2.1.4 --- .../SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj | 2 +- .../TechTalk.SpecFlow.GeneratorTests.csproj | 2 +- .../TechTalk.SpecFlow.PluginTests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj b/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj index 484896c9d..62da4c205 100644 --- a/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj +++ b/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj b/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj index 47b10744f..819d141a9 100644 --- a/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj +++ b/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj @@ -36,7 +36,7 @@ all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers diff --git a/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj b/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj index 380abc2d6..315d00bef 100644 --- a/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj +++ b/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj @@ -27,7 +27,7 @@ all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers From 14c488232e46f6824244c75c5fbbf530151c4428 Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Tue, 24 May 2022 09:41:49 +0200 Subject: [PATCH 02/10] create plugin skeleton --- .../AssemblyHooks.cs | 33 +++++++++ .../Features/Feature.feature | 9 +++ ...rify.SpecFlowPlugin.IntegrationTest.csproj | 68 +++++++++++++++++++ .../AssemblyAttributes.cs | 7 ++ .../SpecFlow.Verify.SpecFlowPlugin.csproj | 23 +++++++ .../SpecFlow.Verify.nuspec | 31 +++++++++ .../VerifyDecorator.cs | 28 ++++++++ .../VerifyGeneratorPlugin.cs | 24 +++++++ .../build/SpecFlow.Verify.props | 5 ++ .../build/SpecFlow.Verify.targets | 9 +++ TechTalk.SpecFlow.sln | 33 +++++++++ 11 files changed, 270 insertions(+) create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/AssemblyHooks.cs create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.props create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.targets diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/AssemblyHooks.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/AssemblyHooks.cs new file mode 100644 index 000000000..d4e7667de --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/AssemblyHooks.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable + +using System.CodeDom.Compiler; +using global::System.Runtime.CompilerServices; +using System.Threading.Tasks; + +[assembly: global::Xunit.TestFramework("TechTalk.SpecFlow.xUnit.SpecFlowPlugin.XunitTestFrameworkWithAssemblyFixture", "TechTalk.SpecFlow.xUnit.SpecFlowPlugin")] +[assembly: global::TechTalk.SpecFlow.xUnit.SpecFlowPlugin.AssemblyFixture(typeof(global::XUnitAssemblyFixture))] + +[GeneratedCode("SpecFlow", "3.10.3-beta")] +public class XUnitAssemblyFixture : global::Xunit.IAsyncLifetime +{ + [MethodImpl(MethodImplOptions.NoInlining)] + public async Task InitializeAsync() + { + var currentAssembly = typeof(XUnitAssemblyFixture).Assembly; + await global::TechTalk.SpecFlow.TestRunnerManager.OnTestRunStartAsync(currentAssembly); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public async Task DisposeAsync() + { + var currentAssembly = typeof(XUnitAssemblyFixture).Assembly; + await global::TechTalk.SpecFlow.TestRunnerManager.OnTestRunEndAsync(currentAssembly); + } +} + +[global::Xunit.CollectionDefinition("SpecFlowNonParallelizableFeatures", DisableParallelization = true)] +public class SpecFlowNonParallelizableFeaturesCollectionDefinition +{ +} +#pragma warning restore diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature new file mode 100644 index 000000000..0f5557b4a --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature @@ -0,0 +1,9 @@ +Feature: Put feature-title here + Put feature description here + +Background: + Given Put your Background here + +Scenario: Put your Scenario here + When Put your Action here + Then Put your Condition here diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj new file mode 100644 index 000000000..c7aa7d351 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj @@ -0,0 +1,68 @@ + + + + + + + net5.0 + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + + <_SpecFlow_Needed_MSBuildGenerator Condition=" '$(MSBuildRuntimeType)' == 'Core'">$(SpecFlow_Core_Generator_TFM) + <_SpecFlow_Needed_MSBuildGenerator Condition=" '$(MSBuildRuntimeType)' != 'Core'">$(SpecFlow_FullFramework_Generator_TFM) + + + + + + + + + + + + + + + + + + + + <_SpecFlow_TaskAssembly>..\..\SpecFlow.Tools.MsBuild.Generation\bin\$(Configuration)\$(_SpecFlow_Needed_MSBuildGenerator)\SpecFlow.Tools.MsBuild.Generation.dll + + + + + + + PreBuild; + $(BuildDependsOn) + + + PreBuild; + $(RebuildDependsOn) + + + \ No newline at end of file diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs new file mode 100644 index 000000000..efe8e8033 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs @@ -0,0 +1,7 @@ +using System.Runtime.CompilerServices; + +#if SPECFLOW_ENABLE_STRONG_NAME_SIGNING +[assembly: InternalsVisibleTo("SpecFlow.ExternalData.SpecFlowPlugin.UnitTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009BD35D42479A68A533445360CA3149C96BF112221527828DCCC15604830999FAD6391912EDBDF591531C4DE9C45E437A3F648A2A3722D04E5A02BECE96522C71060081A14E1E775DF4B6F84D6DB609E3A20D15956D3FEDBFD77B2A9B0D941ACABCBF7C26B87F5696FE4AADAACA69DCB84E7C733D5FF0E9ECEF46656D19BF52A2")] +#else +[assembly: InternalsVisibleTo("SpecFlow.ExternalData.SpecFlowPlugin.UnitTests")] +#endif diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj new file mode 100644 index 000000000..e1c6b1683 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.SpecFlowPlugin.csproj @@ -0,0 +1,23 @@ + + + $(SpecFlow_Generator_TFM) + $(MSBuildThisFileDirectory)SpecFlow.Verify.nuspec + $(SpecFlow_KeyFile) + $(SpecFlow_EnableStrongNameSigning) + $(SpecFlow_PublicSign) + true + + true + true + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + + + + + + + + + diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec new file mode 100644 index 000000000..ed55c5cfb --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec @@ -0,0 +1,31 @@ + + + SpecFlow.Verify + $version$ + SpecFlow.Verify + $author$ + $owner$ + Package to use Verify with SpecFlow + Package to use Verify with SpecFlow + en-US + https://www.specflow.org + images\specflow-icon.png + false + LICENSE.txt + specflow externaldata json + $copyright$ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs new file mode 100644 index 000000000..2c56d78b7 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs @@ -0,0 +1,28 @@ +using TechTalk.SpecFlow.Generator; +using TechTalk.SpecFlow.Generator.CodeDom; +using TechTalk.SpecFlow.Generator.UnitTestConverter; + +namespace SpecFlow.Verify.SpecFlowPlugin; + +public class VerifyDecorator : ITestClassTagDecorator +{ + private readonly CodeDomHelper _codeDomHelper; + + public VerifyDecorator(CodeDomHelper codeDomHelper) + { + _codeDomHelper = codeDomHelper; + } + + public int Priority { get; } + + public bool RemoveProcessedTags { get; } + + public bool ApplyOtherDecoratorsForProcessedTags { get; } + + public bool CanDecorateFrom(string tagName, TestClassGenerationContext generationContext) => true; + + public void DecorateFrom(string tagName, TestClassGenerationContext generationContext) + { + _codeDomHelper.AddAttribute(generationContext.TestClass, "UsesVerify"); + } +} diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs new file mode 100644 index 000000000..cfdbfa797 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs @@ -0,0 +1,24 @@ +using SpecFlow.Verify.SpecFlowPlugin; +using TechTalk.SpecFlow.Generator.Plugins; +using TechTalk.SpecFlow.Generator.UnitTestConverter; +using TechTalk.SpecFlow.Infrastructure; +using TechTalk.SpecFlow.UnitTestProvider; + +[assembly:GeneratorPlugin(typeof(VerifyGeneratorPlugin))] + +namespace SpecFlow.Verify.SpecFlowPlugin +{ + public class VerifyGeneratorPlugin : IGeneratorPlugin + { + public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters, + UnitTestProviderConfiguration unitTestProviderConfiguration) + { + + + generatorPluginEvents.RegisterDependencies += (sender, args) => + { + args.ObjectContainer.RegisterTypeAs("verify"); + }; + } + } +} diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.props b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.props new file mode 100644 index 000000000..a0ff66506 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.props @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.targets b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.targets new file mode 100644 index 000000000..87a1d302d --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/build/SpecFlow.Verify.targets @@ -0,0 +1,9 @@ + + + <_VerifyGeneratorPluginFramework Condition=" '$(MSBuildRuntimeType)' == 'Core'">netcoreapp2.1 + <_VerifyGeneratorPluginFramework Condition=" '$(MSBuildRuntimeType)' != 'Core'">net461 + + <_VerifyGeneratorPluginPath>$(MSBuildThisFileDirectory)$(_VerifyGeneratorPluginFramework)\SpecFlow.Verify.SpecFlowPlugin.dll + + + \ No newline at end of file diff --git a/TechTalk.SpecFlow.sln b/TechTalk.SpecFlow.sln index b89f8ca0c..e51bfedd4 100644 --- a/TechTalk.SpecFlow.sln +++ b/TechTalk.SpecFlow.sln @@ -117,6 +117,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{33D198CB ExternalRepositories\SpecFlow.TestProjectGenerator\Directory.Build.rsp = ExternalRepositories\SpecFlow.TestProjectGenerator\Directory.Build.rsp EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Verify", "Verify", "{229D5199-8A48-4174-AE8F-0B4C91170751}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpecFlow.Verify.SpecFlowPlugin", "Plugins\SpecFlow.Verify\SpecFlow.Verify.SpecFlowPlugin\SpecFlow.Verify.SpecFlowPlugin.csproj", "{93476F8A-EBF1-4DB4-929F-77F5B96D08E0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpecFlow.Verify.SpecFlowPlugin.IntegrationTest", "Plugins\SpecFlow.Verify\SpecFlow.Verify.SpecFlowPlugin.IntegrationTest\SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj", "{68E341C2-12C9-4DAC-AB04-A11C7CF94F30}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -451,6 +457,30 @@ Global {C681C731-49F2-4C93-A730-467251741457}.Release|Any CPU.Build.0 = Release|Any CPU {C681C731-49F2-4C93-A730-467251741457}.VS2010IntegrationTest|Any CPU.ActiveCfg = Debug|Any CPU {C681C731-49F2-4C93-A730-467251741457}.VS2010IntegrationTest|Any CPU.Build.0 = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug-MSTest|Any CPU.ActiveCfg = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug-MSTest|Any CPU.Build.0 = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug-NUnit|Any CPU.ActiveCfg = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug-NUnit|Any CPU.Build.0 = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug-XUnit|Any CPU.ActiveCfg = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Debug-XUnit|Any CPU.Build.0 = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.Release|Any CPU.Build.0 = Release|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.VS2010IntegrationTest|Any CPU.ActiveCfg = Debug|Any CPU + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0}.VS2010IntegrationTest|Any CPU.Build.0 = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug-MSTest|Any CPU.ActiveCfg = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug-MSTest|Any CPU.Build.0 = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug-NUnit|Any CPU.ActiveCfg = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug-NUnit|Any CPU.Build.0 = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug-XUnit|Any CPU.ActiveCfg = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Debug-XUnit|Any CPU.Build.0 = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.Release|Any CPU.Build.0 = Release|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.VS2010IntegrationTest|Any CPU.ActiveCfg = Debug|Any CPU + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30}.VS2010IntegrationTest|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -485,6 +515,9 @@ Global {C681C731-49F2-4C93-A730-467251741457} = {35D24F50-A29E-428A-8649-275C73C1E646} {35D24F50-A29E-428A-8649-275C73C1E646} = {16EAF4F9-9860-4BB9-8992-98522E68E570} {33D198CB-E5C7-4922-8285-246A0EFA752D} = {974420E8-FEEA-4564-B4CE-BE06F7457E3B} + {229D5199-8A48-4174-AE8F-0B4C91170751} = {8BE0FE31-6A52-452E-BE71-B8C64A3ED402} + {93476F8A-EBF1-4DB4-929F-77F5B96D08E0} = {229D5199-8A48-4174-AE8F-0B4C91170751} + {68E341C2-12C9-4DAC-AB04-A11C7CF94F30} = {229D5199-8A48-4174-AE8F-0B4C91170751} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A4D0636F-0160-4FA5-81A3-9784C7E3B3A4} From b4f7e9d8c5fe567171c595e9d81e3c5cc29e19e2 Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Tue, 24 May 2022 14:49:44 +0200 Subject: [PATCH 03/10] bring it to work --- .../Features/Feature.feature | 13 +++++------ ...rify.SpecFlowPlugin.IntegrationTest.csproj | 4 ++-- .../Steps/Steps.cs | 22 +++++++++++++++++++ ...eature.CheckIfVerifyIsWorking.verified.txt | 1 + .../VerifyDecorator.cs | 13 +++++------ .../VerifyGeneratorPlugin.cs | 4 +--- 6 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/VerifyTestFeature.CheckIfVerifyIsWorking.verified.txt diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature index 0f5557b4a..0615664e4 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature @@ -1,9 +1,6 @@ -Feature: Put feature-title here - Put feature description here +Feature: Verify Test -Background: - Given Put your Background here - -Scenario: Put your Scenario here - When Put your Action here - Then Put your Condition here +Scenario: Check if Verify is working + When I try Verify with SpecFlow + Then it works + diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj index c7aa7d351..2a01f7e57 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj @@ -5,11 +5,12 @@ net5.0 + true - + all @@ -46,7 +47,6 @@ - diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs new file mode 100644 index 000000000..8f4d16bb7 --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs @@ -0,0 +1,22 @@ +using System.Threading.Tasks; +using TechTalk.SpecFlow; +using VerifyXunit; + +namespace SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.Steps +{ + [Binding] + internal class Steps + { + [When("I try Verify with SpecFlow")] + public async Task ITryVerifyWithSpecFlow() + { + await Verifier.Verify("value"); + } + + [Then("it works")] + public void ItWorks() + { + + } + } +} diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/VerifyTestFeature.CheckIfVerifyIsWorking.verified.txt b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/VerifyTestFeature.CheckIfVerifyIsWorking.verified.txt new file mode 100644 index 000000000..3c877c57a --- /dev/null +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/VerifyTestFeature.CheckIfVerifyIsWorking.verified.txt @@ -0,0 +1 @@ +value \ No newline at end of file diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs index 2c56d78b7..7f99ed423 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyDecorator.cs @@ -4,7 +4,7 @@ namespace SpecFlow.Verify.SpecFlowPlugin; -public class VerifyDecorator : ITestClassTagDecorator +public class VerifyDecorator : ITestClassDecorator { private readonly CodeDomHelper _codeDomHelper; @@ -13,16 +13,13 @@ public VerifyDecorator(CodeDomHelper codeDomHelper) _codeDomHelper = codeDomHelper; } - public int Priority { get; } + public int Priority { get; } = 0; - public bool RemoveProcessedTags { get; } + public bool CanDecorateFrom(TestClassGenerationContext generationContext) => true; - public bool ApplyOtherDecoratorsForProcessedTags { get; } - - public bool CanDecorateFrom(string tagName, TestClassGenerationContext generationContext) => true; - - public void DecorateFrom(string tagName, TestClassGenerationContext generationContext) + public void DecorateFrom(TestClassGenerationContext generationContext) { _codeDomHelper.AddAttribute(generationContext.TestClass, "UsesVerify"); + } } diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs index cfdbfa797..7b22a5cae 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyGeneratorPlugin.cs @@ -13,11 +13,9 @@ public class VerifyGeneratorPlugin : IGeneratorPlugin public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters, UnitTestProviderConfiguration unitTestProviderConfiguration) { - - generatorPluginEvents.RegisterDependencies += (sender, args) => { - args.ObjectContainer.RegisterTypeAs("verify"); + args.ObjectContainer.RegisterTypeAs("verify"); }; } } From acf4d7a389ac4de934e09076ce6f01f2966beaa3 Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Mon, 8 Aug 2022 13:33:20 +0200 Subject: [PATCH 04/10] adjust filename generation --- .../Features/Feature.feature | 8 +++ .../Steps/Steps.cs | 70 ++++++++++++++----- .../AssemblyAttributes.cs | 5 -- 3 files changed, 62 insertions(+), 21 deletions(-) diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature index 0615664e4..57112974a 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Feature.feature @@ -4,3 +4,11 @@ Scenario: Check if Verify is working When I try Verify with SpecFlow Then it works +Scenario Outline: Check if Verify is working with Example Tables + When I try Verify with SpecFlow for Parameter '' + Then it works + +Examples: + | Parameter | + | 1 | + | 2 | 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 8f4d16bb7..e15c51430 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs @@ -1,22 +1,60 @@ -using System.Threading.Tasks; +using System.Collections; using TechTalk.SpecFlow; -using VerifyXunit; +using System.Linq; -namespace SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.Steps +namespace SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.Steps; + +[Binding] +internal class 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; + + if (_scenarioContext.ScenarioInfo.Arguments.Count > 0) + { + scenarioInfoTitle += "_"; + + 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() + { + await Verifier.Verify("value"); + } + + [When(@"I try Verify with SpecFlow for Parameter '([^']*)'")] + public async Task WhenITryVerifyWithSpecFlowForParameter(string p0) + { + await Verifier.Verify("value"); + } + + [Then("it works")] + public void ItWorks() { - [When("I try Verify with SpecFlow")] - public async Task ITryVerifyWithSpecFlow() - { - await Verifier.Verify("value"); - } - - [Then("it works")] - public void ItWorks() - { - - } } } diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs index efe8e8033..3c7a5c375 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/AssemblyAttributes.cs @@ -1,7 +1,2 @@ using System.Runtime.CompilerServices; -#if SPECFLOW_ENABLE_STRONG_NAME_SIGNING -[assembly: InternalsVisibleTo("SpecFlow.ExternalData.SpecFlowPlugin.UnitTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009BD35D42479A68A533445360CA3149C96BF112221527828DCCC15604830999FAD6391912EDBDF591531C4DE9C45E437A3F648A2A3722D04E5A02BECE96522C71060081A14E1E775DF4B6F84D6DB609E3A20D15956D3FEDBFD77B2A9B0D941ACABCBF7C26B87F5696FE4AADAACA69DCB84E7C733D5FF0E9ECEF46656D19BF52A2")] -#else -[assembly: InternalsVisibleTo("SpecFlow.ExternalData.SpecFlowPlugin.UnitTests")] -#endif From fbfddb994fdf547142a07e3b1d34790055dec042 Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Mon, 8 Aug 2022 16:20:40 +0200 Subject: [PATCH 05/10] rebase branch --- .../SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj index 2a01f7e57..e66d4421a 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj @@ -11,12 +11,12 @@ - - + + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers From 1ecdffa721bcae18afc075a7fd46757187915f11 Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Tue, 9 Aug 2022 11:15:58 +0200 Subject: [PATCH 06/10] fix filename generation --- .../SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj | 2 +- .../SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj b/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj index 62da4c205..484896c9d 100644 --- a/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj +++ b/Plugins/SpecFlow.ExternalData/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests/SpecFlow.ExternalData.SpecFlowPlugin.UnitTests.csproj @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj index e66d4421a..41627640c 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj @@ -4,19 +4,19 @@ - net5.0 + net6.0 true - + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers From 2aa2f375fdc04d78474cf0558ba968b30d87a430 Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Wed, 10 Aug 2022 13:09:38 +0200 Subject: [PATCH 07/10] fix naming of file --- .../Steps/Steps.cs | 12 ++++-------- .../SpecFlow.Verify.nuspec | 5 +++-- .../TechTalk.SpecFlow.GeneratorTests.csproj | 2 +- .../TechTalk.SpecFlow.PluginTests.csproj | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) 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 e15c51430..7bfc4e63a 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Steps/Steps.cs @@ -24,21 +24,17 @@ public void SetupVerify() { string scenarioInfoTitle = _scenarioContext.ScenarioInfo.Title; - if (_scenarioContext.ScenarioInfo.Arguments.Count > 0) + foreach (DictionaryEntry scenarioInfoArgument in _scenarioContext.ScenarioInfo.Arguments) { - scenarioInfoTitle += "_"; - - foreach (DictionaryEntry scenarioInfoArgument in _scenarioContext.ScenarioInfo.Arguments) - { - scenarioInfoTitle += "_" + scenarioInfoArgument.Value; - } + scenarioInfoTitle += "_" + scenarioInfoArgument.Value; } - + return new PathInfo( Path.Combine(projectDirectory, _featureContext.FeatureInfo.FolderPath), _featureContext.FeatureInfo.Title, scenarioInfoTitle); }); + } [When("I try Verify with SpecFlow")] diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec index ed55c5cfb..536739723 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec @@ -16,14 +16,15 @@ $copyright$ + - + - + diff --git a/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj b/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj index 819d141a9..47b10744f 100644 --- a/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj +++ b/Tests/TechTalk.SpecFlow.GeneratorTests/TechTalk.SpecFlow.GeneratorTests.csproj @@ -36,7 +36,7 @@ all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers diff --git a/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj b/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj index 315d00bef..380abc2d6 100644 --- a/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj +++ b/Tests/TechTalk.SpecFlow.PluginTests/TechTalk.SpecFlow.PluginTests.csproj @@ -27,7 +27,7 @@ all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers From 9f85f17052d54562ce9916ea2a8d4afdff6baffd Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Wed, 10 Aug 2022 13:42:13 +0200 Subject: [PATCH 08/10] finalize filename generation put into runtime plugin --- ...orking with Example Tables_1.verified.txt} | 0 ...working with Example Tables_2.verified.txt | 1 + ...st.Check if Verify is working.verified.txt | 1 + .../Steps/Steps.cs | 34 +------------- .../SpecFlow.Verify.SpecFlowPlugin.csproj | 1 + .../VerifyRuntimePlugin.cs | 47 +++++++++++++++++++ 6 files changed, 51 insertions(+), 33 deletions(-) rename Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/{Steps/VerifyTestFeature.CheckIfVerifyIsWorking.verified.txt => Features/Verify Test.Check if Verify is working with Example Tables_1.verified.txt} (100%) create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working with Example Tables_2.verified.txt create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/Features/Verify Test.Check if Verify is working.verified.txt create mode 100644 Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/VerifyRuntimePlugin.cs 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); + }); + } +} From f305b51587c1360126148ad201af0072e87b87da Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Wed, 10 Aug 2022 14:03:30 +0200 Subject: [PATCH 09/10] fix SpecFlow.Verify nuspec --- .../SpecFlow.Verify.nuspec | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec index 536739723..4c0832eb3 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin/SpecFlow.Verify.nuspec @@ -14,18 +14,33 @@ LICENSE.txt specflow externaldata json $copyright$ + - - + + + + + + + + + + + + + - + + + + From 6abde0599780ac62081c51894df4ece9dd401ed4 Mon Sep 17 00:00:00 2001 From: Andreas Willich Date: Wed, 10 Aug 2022 15:03:16 +0200 Subject: [PATCH 10/10] fix build dependencies --- .../SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj index 41627640c..999fcf076 100644 --- a/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj +++ b/Plugins/SpecFlow.Verify/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest/SpecFlow.Verify.SpecFlowPlugin.IntegrationTest.csproj @@ -36,6 +36,7 @@ +