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
    @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
    Vitalii Lisovyi
    @vili1901_gitlab
    @yrubakhau have you reported your issue, because I have the same error after build project with 'msbuild' and successful with 'dotnet'. If yes, please share the link. Thanks
    Travis Lindahl
    @travislindahl
    @SabotageAndi how do you allow plugins such as SpecFlow.NUnit plugin, which targets .NET 4.6.1 and .NET Core 2.1, to be used with .NET Core 3.1? When trying to setup a custom plugin to be used in a .NET Core 3.1 test application, I am unable to install the Nuget Package due to incompatibilities with .NET Core 2.1 and 3.1.
    Andreas Willich
    @SabotageAndi
    @travislindahl runtime or generator?
    We don't reference the plugin assembly during compile time. We do stuff in MSBuild for that.
    Do you have the source of the plugin somewhere available that I can have a look at them?
    Travis Lindahl
    @travislindahl
    @SabotageAndi generator. Source for NUnit test project and Custom Plugin project are at https://github.com/travislindahl/SpecFlow-PluginExample