SpecFlowOSS / SpecFlow.VisualStudio

Visual Studio extension of SpecFlow (extracted from the main SpecFlow repo)
Other
67 stars 73 forks source link

Scenario Outline place holders not being replaced correctly when strings in examples. #153

Open adzpond opened 6 years ago

adzpond commented 6 years ago

Scenario Outline place holders not being replaced correctly when strings in examples.

SpecFlow Version:

Used Test Runner

Version number:1.2.0

Visual Studio Version

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<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 and And Click on the LogIn button Then Successful LogIN message should display Examples: | username | password | | testuser_1 | Test@123 | | testuser_2 | Test@153 |

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/

SabotageAndi commented 6 years ago

@adzpond please reformat the scenario. And I don't see any bold marked. I think Markdown does not show it.

adzpond commented 6 years ago

I did notice that. I have updated the description. Does that help?

SabotageAndi commented 6 years ago

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.

adzpond commented 6 years ago

Ok, thanks for a quick turn around.