by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Andreas Willich
    @SabotageAndi
    image.png
    for generator plugins you have to ship it within the package
    but you don't need the dependency on the package itself
    Prab
    @TotalTest

    How do I include that? It doesn't seem that the Newtonsoft.Json dll is in the \bin\Debug\netstandard2.0 directory (once built) so it can't be copied to the build directory, like the customplugin dll can.

    So essentially the below doesn't seem to work for standard (final two lines):

    <files>
    <file src="build\**\*" target="build"/>
    <file src="bin\$config$\net471\SpecFlow.Contrib.Variants.SpecFlowPlugin.*" target="build\net471"/>
    <file src="bin\$config$\netstandard2.0\SpecFlow.Contrib.Variants.SpecFlowPlugin.dll" target="build\netstandard2.0"/>
    <file src="bin\$config$\netstandard2.0\SpecFlow.Contrib.Variants.SpecFlowPlugin.pdb" target="build\netstandard2.0"/>

    <file src="bin\$config$\net471\Newtonsoft.Json.*" target="build\net471"/>
    <file src="bin\$config$\netstandard2.0\Newtonsoft.Json.dll" target="build\netstandard2.0"/>
    </files>

    Prab
    @TotalTest

    I managed to figure it out, for standard there is a .deps file in the built output, include this file in the package. For framework just include the dependant dll

    <file src="bin\$config$\net471\Newtonsoft.Json.*" target="build\net471"/>

    <file src="bin\$config$\netstandard2.0\SpecFlow.Contrib.Variants.SpecFlowPlugin.*" target="build\netstandard2.0"/>

    Josh Keegan
    @JoshKeegan
    Hi, the official specflow plugins are versioned along with specflow itself, e.g. both specflow and specflow.xunit are currently on 3.1.89.
    Is there a reason for this & should unofficial packages do the same, or depend on a range of specflow versions?
    Andreas Willich
    @SabotageAndi
    @JoshKeegan The reason is, that we publish all packages at once, also when there were no changes in them. It would be too much confusing having multiple packages which have a different latest version.
    Andreas Willich
    @SabotageAndi

    What "unofficial" packages do with their version is up to them. We don't have here any suggestions.
    I would suggest, that you limit your dependency on the supported Major.Minor version number. Reason is, that when we change the plugin interface, we increase the minor version.

    There are some plugins out on nuget, that only have SpecFlow >=1.9 as dependency. The user can add these nuget packages, but they will not work, because the plugin interface changed a lot since 1.9. https://www.nuget.org/packages/Baseclass.Contrib.SpecFlow.Selenium.NUnit/1.3.2-tn40support2 is an example for it.

    Josh Keegan
    @JoshKeegan
    Thanks Adreas, that makes sense :)
    Gemma Buckley
    @midgetgem
    Hi, I have a custom generator plugin, added to my C# project with a package reference, but how do I configure the plugin? I want to add an entry that will be picked up when GeneratorPluginParameters is passed into the IGeneratorPlugin Initialize method. Should I be adding an entry to the app.config, or the specflow.json file? Thanks in advance
    drosenba
    @drosenba
    I asked on Stakcoverflow: https://stackoverflow.com/questions/61258555/how-to-create-a-plugin-for-specflow-feature-level-templates , but did not get any response. Maybe this is a better channel to look for some guidance/direction. Also, is it yet possible to create plugins for SpecFlow.NetCore? The docs say "Runtime plugins need to target .NET Framework 4.5 and .NET Standard 2.0."
    drosenba
    @drosenba
    It's not even clear to me whether I need to create a Generator plugin or a Runtime plugin (or both). There is no description as to the purpose of these plugin types.
    Vamsi TP
    @vamsitp
    @SabotageAndi - Is there a sample that shows the usage of a generator-plugin once it's packaged as a Nuget? Do we just need to add a nuget reference to the generator-plugin in the actual test-project, or do we have a way to specify what generators to use within the nuget? Will all the classes that implement the IGeneratorPlugin interface automatically kick in?
    Andreas Willich
    @SabotageAndi
    @vamsitp there is no ordering or additional configuration. You add the NuGet PackageReference to the test project and that was ist. all IGeneratorPlugin implementations with the marker attribute are called
    Pavel Anihimovsky
    @pavelanihimovsky
    Hi, I'm working on runtime plugin for tool that allows to collect information about test executions (https://github.com/aquality-automation/aquality-tracking) and I faced with an issue. The issue relates to Scenario Outline. I have to create separate test for each Example in this tool. If I use scenarioContext.ScenarioInfo.Title I get the same name for all tests of Scenario Outline, but I want to get something like this as name of test in this tool Feature name: Scenario name: {example_number}. Please let me know is it possible to get Examples of Scenario Outline in runtime and how or something else that can help me with this?
    Andreas Willich
    @SabotageAndi
    @pavelanihimovsky With SpecFlow 3.3 you can get the parameters of a ScenarioOutline. PR is here: SpecFlowOSS/SpecFlow#1988
    Pavel Anihimovsky
    @pavelanihimovsky
    @SabotageAndi Thanks
    Clément MARTY
    @AdCodicem
    Hi! I just created a dependency injection plugin for Specflow which use the Microsoft.Extensions.DependencyInjection nuget : https://github.com/Back-To-The-Coding/SpecFlow.Microsoft.DependencyInjection
    I wondered if I can link my plugin in the Specflow wiki ?
    Also it's basically my first contribution to an open source project :)
    Andreas Willich
    @SabotageAndi
    @Back-To-The-Coding sure, we have a page for that: https://specflow.org/documentation/Available-Plugins/
    in the bottom is a link to the wiki page to edit it
    Clément MARTY
    @AdCodicem
    Thank you @SabotageAndi !
    Clément MARTY
    @AdCodicem
    I just saw that somebody has already developped a similar plugin, so I won't add mine to not fragment the plugin list.
    How do I haven't seen it earlier ? ^^"
    Andreas Willich
    @SabotageAndi
    @Back-To-The-Coding Please add your plugin to the page. Choice is always good. I have no idea if the other plugin is active developed or which SpecFlow version it is supporting.
    Marc Müller
    @marc-mueller
    Good morning! I'm currently a little bit lost since I haven't found it in the documentation or in a sample. Maybe somebody could give me a hint. We are using Specflow 3 with MSTest v2. We need to change the code behind file generation that the test method uses a custom attribute instead of the [TestMethod] attribute. How do I do that? Writing a generator plugin and register a custom MSTest generator? Do I have to write the generator from scratch? I does not look like I can simply change the attribute type of the existing one, right? Thanks your your help!
    That should work, but I never tried it.
    Btw, why do you need another attribute than [TestMethod] on the methods?
    Marc Müller
    @marc-mueller

    Hi @SabotageAndi , thanks a lot for your fast feedback. Do I need to create a nuget package for the plugin or can I register it just with a project dependency?

    The reason why is a good question ;-). We basically use the test for functional testing of the system. But there is a new additional requirement that we need to also verify the correctnes of the system under load where we are executing the same tests during multiple hours over and over. To just reuse the existing test dlls for that, we created a custom TestMethod attribute where we run the same test according to the load test configuration multiple times over a period of time. So having a custom attribute, we can use the test assemblies for both testing purposes and just set a flag in the runsettings during test execution.

    Marc Müller
    @marc-mueller
    I built a custom nuget package, but something is still missing. It defaults to nunit generation currently. I also registered the new generator type, but it did not help
     public class GeneratorPlugin : IGeneratorPlugin
        {
            public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters, UnitTestProviderConfiguration unitTestProviderConfiguration)
            {
                unitTestProviderConfiguration.UseUnitTestProvider("custommstest");
                generatorPluginEvents.RegisterDependencies += GeneratorPluginEvents_RegisterDependencies;
            }
    
            private void GeneratorPluginEvents_RegisterDependencies(object sender, RegisterDependenciesEventArgs e)
            {
                e.ObjectContainer.RegisterTypeAs<CustomMsTestV2GeneratorProvider, IUnitTestGeneratorProvider>("custommstest");
            }
        }
    Sonu Davidson
    @sonudavidson
    [image.png]
    image.png
    image.png
    Hi,
    I'm using SpecFlow 3 with NUnit 3 and I'm adding a custom NUnit attribute "ScenarioContent" to each example of a Scenario Outline.
    The code behind the feature is generated looks like this
    While the background code is generated correctly, but the NUnit 3 result XML file generated by the test runner doesn't link my property to the example <test-case> but to the <test-suite>
    image.png
    Sonu Davidson
    @sonudavidson
    Appreciate if anyone can point me what I am doing wrong or where is it going wrong!
    Thanks in advance!
    Andreas Willich
    @SabotageAndi
    @sonudavidson I would ask the NUnit people. SpecFlow doesn't influence anything what is written to the result xml.
    @sonudavidson btw, this would be a nice addition for SpecFlow itself and have this for all unit test providers.
    Sonu Davidson
    @sonudavidson
    @SabotageAndi Thanks for the quick reply. I will also check with NUnit dev team.
    I'd be happy to create a PR if u think its a good addition for the Specflow. Thank you!
    Andreas Willich
    @SabotageAndi
    @sonudavidson :+1:
    I would try to reproduce your issue without SpecFlow for the NUnit Team. Not that we have a play of hot potatoes between us ;-)
    Sonu Davidson
    @sonudavidson
    @SabotageAndi (Y)
    :thumbsup:
    yrubakhau
    @yrubakhau

    Hello, I have a question regarding update to Specflow 3.3.30 - I use a custom generator plugin and previously it was targeting netstandard2.0 but after update I had to change target to netcoreapp2.1, otherwise it won't compile due to

    CS1705    Assembly 'TechTalk.SpecFlow.Parser' with identity 'TechTalk.SpecFlow.Parser, Version=3.3.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41' uses 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    After moving to netcoreapp2.1 it started to compile but now when I build tests in visual studio I get an error during generating feature files:

    Error    MSB4018    The "GenerateFeatureFileCodeBehindTask" task failed unexpectedly.
    System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
    File name: 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
       at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
       at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
       at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
       at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
       at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
       at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
       at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
       at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
       at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
       at TechTalk.SpecFlow.Generator.Plugins.GeneratorPluginLoader.LoadPlugin(PluginDescriptor pluginDescriptor)
       at TechTalk.SpecFlow.Generator.GeneratorContainerBuilder.LoadPlugins(ObjectContainer container, GeneratorPluginEvents generatorPluginEvents, UnitTestProviderConfiguration unitTestProviderConfiguration, IEnumerable`1 generatorPlugins)
       at TechTalk.SpecFlow.Generator.GeneratorContainerBuilder.CreateContainer(SpecFlowConfigurationHolder configurationHolder, ProjectSettings projectSettings, IEnumerable`1 generatorPluginInfos, IObjectContainer parentObjectContainer)
       at SpecFlow.Tools.MsBuild.Generation.WrappedGeneratorContainerBuilder.BuildGeneratorContainer(SpecFlowConfigurationHolder specFlowConfigurationHolder, ProjectSettings projectSettings, IReadOnlyCollection`1 generatorPluginInfos, IObjectContainer rootObjectContainer)
       at SpecFlow.Tools.MsBuild.Generation.GenerateFeatureFileCodeBehindTaskExecutor.Execute()
       at SpecFlow.Tools.MsBuild.Generation.GenerateFeatureFileCodeBehindTask.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

    However solution can be built successfully using dotnet build.

    yrubakhau
    @yrubakhau
    The first error is reproducible in GeneratorOnlyPlugin example if you just add use Parser in any place, e.g.:
    public class SampleGeneratorPlugin : IGeneratorPlugin
        {
            public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters,
                UnitTestProviderConfiguration unitTestProviderConfiguration)
            {
                var pars = new SpecFlowGherkinParser(new GherkinDialectProvider());
            }
        }
    Andreas Willich
    @SabotageAndi
    @yrubakhau Please file an issue on GitHub and attach a project where we can reproduce this issue
    Prab
    @TotalTest

    Hi, I'm in the process of upgrading my plugin to support 3.3.57. However, I'm seeing different examples from the docs and the sample generator plugin, and yet something different for the xunit/mstest plugins. This is regarding TargetFrameworks and the .targets file.

    Docs: has netecoreapp2.1 and net471
    https://docs.specflow.org/projects/specflow/en/latest/Extend/Plugins.html

    <_SampleGeneratorPluginFramework Condition=" '$(MSBuildRuntimeType)' == 'Core'">netecoreapp2.1</_SampleGeneratorPluginFramework>
    <_SampleGeneratorPluginFramework Condition=" '$(MSBuildRuntimeType)' != 'Core'">net471</_SampleGeneratorPluginFramework>

    Sample: has netstandard2.0 and net471
    https://github.com/SpecFlowOSS/SpecFlow-Examples/blob/master/Plugins/GeneratorOnlyPlugin/GeneratorPlugin/build/SpecFlow.SamplePlugin.targets

    <_SampleGeneratorPluginFramework Condition=" '$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_SampleGeneratorPluginFramework>
    <_SampleGeneratorPluginFramework Condition=" '$(MSBuildRuntimeType)' != 'Core'">net471</_SampleGeneratorPluginFramework>

    xunit generation plugin: has netcoreapp2.1 and net461

    <_SpecFlow_xUnitGeneratorPlugin Condition=" '$(MSBuildRuntimeType)' == 'Core'" >netcoreapp2.1</_SpecFlow_xUnitGeneratorPlugin>
    <_SpecFlow_xUnitGeneratorPlugin Condition=" '$(MSBuildRuntimeType)' != 'Core'" >net461</_SpecFlow_xUnitGeneratorPlugin>

    What should my .props file have. And also what should TargetFrameworks contain?

    My plugin currently has the below in .csproj:

    <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>

    and the below in .targets

    <_SpecFlowContribVariantsPluginFramework Condition=" '$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_SpecFlowContribVariantsPluginFramework
    <_SpecFlowContribVariantsPluginFramework Condition=" '$(MSBuildRuntimeType)' != 'Core'">net471</_SpecFlowContribVariantsPluginFramework>
    Andreas Willich
    @SabotageAndi
    Oops. We didn't update this documentation after 3.3 release.
    This are the Targetframeworks that are correct:
    Runtime plugin: .NET 4.6.1 and .NET Standard 2.0
    Generator plugin: .NET 4.6.1 and .NET Core 2.1
    I will fix the documentation during the day