SpecFlow.VisualStudio
SpecFlow.VisualStudio copied to clipboard
Scenario Outline place holders not being replaced correctly when strings in examples.
Scenario Outline place holders not being replaced correctly when strings in examples.
SpecFlow Version:
- [ x] 2.3.2
- [ ] 2.2
- [ ] 2.1
- [ ] 2.0
- [ ] 1.9
Used Test Runner
- [ ] SpecFlow+Runner
- [ x] MSTest
- [ ] NUnit
- [ ] Xunit
Version number:1.2.0
Visual Studio Version
- [x ] VS 2017
- [ ] VS 2015
- [ ] VS 2013
Are the latest Visual Studio updates installed?
- [x ] Yes
- [ ] No
.NET Framework:
- [x ] >= .NET 4
- [ ] before .NET 4
Test Execution Method:
- [x ] Visual Studio Test Explorer
- [ ] TFS/VSTS – Task – PLEASE SPECIFY THE NAME OF THE TASK
- [ ] Command line – PLEASE SPECIFY THE FULL COMMAND LINE
<SpecFlow> Section in app.config
<specFlow>
<!-- 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 -->
<unitTestProvider name="MsTest" />
</specFlow>
Repro Project
Issue Description
When using a Scenario Outline that has strings in the examples table the string value is used in the step name as opposed to swapping the place holder with a wild card. If a combination of alphas and numbers are used, the alpha is used in the step name but the number is replaced with the regex.
Steps to Reproduce
Using this Scenario Outline
Scenario Outline: Successful Login with Valid Credentials
Given User is at the Home Page
And Navigate to LogIn Page
When User enter
Generates this
[Given(@"User is at the Home Page")]
public void GivenUserIsAtTheHomePage()
{
ScenarioContext.Current.Pending();
}
[Given(@"Navigate to LogIn Page")]
public void GivenNavigateToLogInPage()
{
ScenarioContext.Current.Pending();
}
[When(@"User enter testuser_(.*) and Test@(.*)")]
public void WhenUserEnterTestuser_AndTest(int p0, int p1)
{
ScenarioContext.Current.Pending();
}
[When(@"Click on the LogIn button")]
public void WhenClickOnTheLogInButton()
{
ScenarioContext.Current.Pending();
}
[Then(@"Successful LogIN message should display")]
public void ThenSuccessfulLogINMessageShouldDisplay()
{
ScenarioContext.Current.Pending();
}
The place holders are replaced with the string values in the first row of the examples table as opposed to a wildcard for the entire value as I would have expected. If the string is put in quotes then it works as expected.
The generated attribute looks like this
[When(@"User enter testuser_(.*) and Test@(.*)")]
Where "testuser_" and "Test@" are values from the examples table, whereas I would have expected it to be generated as below.
[When(@"User enter (.*) and (.*)")]
The example in this article demonstrates how I would have thought it should work.
http://toolsqa.com/specflow/data-driven-testing-in-specflow/
@adzpond please reformat the scenario. And I don't see any bold marked. I think Markdown does not show it.
I did notice that. I have updated the description. Does that help?
Sometimes the VS Integration doesn't correctly guess what are parameters. We recommend for that to always use single quotes (') to "mark" parameters. Also if you have a Scenario Outline with example tables.
Ok, thanks for a quick turn around.