SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

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

Open stevenmolencsat opened this issue 1 year ago • 0 comments

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

stevenmolencsat avatar Jul 02 '24 17:07 stevenmolencsat