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.25k stars 754 forks source link

ValueRetriever not being applied when DataSet is part of Example in Scenario Outline #2754

Open stevenmolencsat opened 5 months ago

stevenmolencsat commented 5 months ago

SpecFlow Version

3.9.40

Which test runner are you using?

MSTest

Test Runner Version Number

3.9.40

.NET Implementation

.NET 6.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

SpecFlow Section in app.config or content of specflow.json

No response

Issue Description

When trying to use a ValueRetriever for a Scenario Outline Example, the contents of the cell are passed to each scenario, instead of the contents from the ValueRetriever.

Steps to Reproduce

Scenario Outline: deserialize xyz
    Given I have a new xyz
    When I deserialize the data from '<StringFile>'
    Then It should give me a valid object

    Examples: 
    | StringFile                              |
    | Examples\\XML\\xyz.xml |
[Binding]
public static class Hooks
{
    [BeforeTestRun]
    public static void BeforeTestRun()
    {
        Service.Instance.ValueRetrievers.Register(new StringFileValueRetriever());
    }
}
{
    public bool CanRetrieve(KeyValuePair<string, string> keyValuePair, Type targetType, Type propertyType)
    {
        if (!keyValuePair.Key.Equals("StringFile", StringComparison.Ordinal))
        {
            return false;
        }

        if (File.Exists(keyValuePair.Value))
        {
            return true;
        }

        return false;
    }
    public object Retrieve(KeyValuePair<string, string> keyValuePair, Type targetType, Type propertyType)
    {
        return File.ReadAllText(keyValuePair.Value);
    }
}

Within the step definition, I am getting Examples\XML\xyz.xml

Link to Repro Project

No response