Closed asimontsev closed 2 years ago
Yeah, that looks like a bug. I think it is happening somewhere here: https://github.com/SpecFlowOSS/SpecFlow/blob/master/TechTalk.SpecFlow.Generator/Generation/UnitTestMethodGenerator.cs#L347
If somebody wants to fix this, a good starting point would be to write some unit tests for the method, before fixing it.
I have a first draft of a working prototype for the fix. Putting together unit tests and will submit a PR. The problem stems from the Regex pattern used in the GetSubstitutedString method of the ScenarioPartHelper class. https://github.com/SpecFlowOSS/SpecFlow/blob/ba1aae24ef2389effe5eecdad300e3455886667a/TechTalk.SpecFlow.Generator/Generation/ScenarioPartHelper.cs#L162
Awesome @clrudolphi
PR submitted. First timer here; let me know what else you'd like to see in the PR.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
SpecFlow Version
3.9.58
Which test runner are you using?
xUnit
Test Runner Version Number
2.4.1
.NET Implementation
.NET Core 3.1
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
{ "bindingCulture": { "name": "en-us" }, "language": { "feature": "en-us" } }
Issue Description
I am writing a test which looks like this:
However, the
<Mode>
parameter is not replaced and my step receives the XML content unchanged. According to the docs, multi-line text should support such variables. If I put this variable outside of an XML tag, it is replaced, for example, this one works:I have noticed the suggestion to add the single quotes around the variable, but it did not help.
Eventually, I have found out that I can use the
ScenarioInfo
- I am receiving an instance of ScenarioInfo through Dependency Injection and add the following code to my step definition:However, I believe this sort of code should be executed by SpecFlow, rather than the step definitions.
Hope this makes sense.
Steps to Reproduce
Expected: the parameter is replaced by the value from the Examples table
Actual: the Doc String is passed to the step definition unchanged.
Simplified example:
Link to Repro Project
No response