SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.24k stars 754 forks source link

Duplicate step argument transformations created for external assemblies #1004

Open jtdubya opened 6 years ago

jtdubya commented 6 years ago

Duplicate step argument transformations created for external assemblies and causing false "Multiple step transformation matches to the input" warning

SpecFlow Version:

Used Test Runner

Version number: 1.6.3

Visual Studio Version

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<SpecFlow> Section in app.config

  <specFlow>
        <stepAssemblies>
            <stepAssembly assembly="CalculatorSteps" />
        </stepAssemblies>

        <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
        <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
        <!-- use unit test provider SpecRun+NUnit or SpecRun+MsTest for being able to execute the tests with SpecRun and another provider -->
        <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
        <!-- use unit test provider SpecRun+NUnit or SpecRun+MsTest for being able to execute the tests with SpecRun and another provider -->
        <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --><!-- use unit test provider SpecRun+NUnit or SpecRun+MsTest for being able to execute the tests with SpecRun and another provider --><unitTestProvider name="SpecRun" />
        <plugins>
            <add name="SpecRun" />
        </plugins>
</specFlow>

Repro Project

https://github.com/jtdubya/SpecFlowTransformIssueExample

Issue Description

Duplicate step argument transformations are being created for steps in external assemblies which give the false "warning: Multiple step transformation matches to the input" in the output. The step argument transformations, identified by the [StepArgumentTransformation] annotation, that are referenced from external assemblies are duplicated in the binding registry.

Steps to Reproduce

Create step argument transformations is a separate project from the test project and reference them in the specflow>stepAssemblies section of the app.config

nikoudel commented 5 years ago

The bug is here.

AppConfigConfigurationLoader.LoadAppConfig is run multiple times (which also feels flawed btw) and each time it copies previous specFlowConfiguration.AdditionalStepAssemblies list only to add configSection.StepAssemblies once again.