Search code examples
visual-studiobddspecflowgherkin

SpecFlow Step Generation for Scenario Outline Generating Incorrect Methods


I'm new in Visual Studio. I'm using Visual Studio 2015 with SpecFlow. Below is the Feature File:

@mytag
Scenario Outline: Successful Authentication
    Given I am a user of type <user>
    When I hit the application URL
    And I provide <email>
    And I click on Log In Button
    Then I will be landed to the Home Page
    And I will be able to see <name> on the Home Page

Examples: 
    | user      | email          | name  |
    | admin     | a.b@example.com | alpha |
    | non-admin | b.c@example.com | beta  |

When I generate the step definitions I'm expecting parameters in place of the variables, instead the method is generated as below:

[Given(@"I am a user of type admin")]
public void GivenIAmAUserOfTypeAdmin()
{
    ScenarioContext.Current.Pending();
}

I was instead expecting a method like:

[Given(@"I am a user of type '(.*)'")]
public void GivenIAmAUserOfType(string p0)
{
    ScenarioContext.Current.Pending();
}

What am I missing?


Solution

  • As an example, surrounding the <user> in the Given step with '' like this,

    Given I am a user of type '<user>'
    

    will generate the desired results. It's probably needed in order to recognize the regular expression.

    enter image description here