Abhi Nandan
Abhi Nandan

Reputation: 195

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     | [email protected] | alpha |
    | non-admin | [email protected] | 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?

Upvotes: 0

Views: 230

Answers (1)

Daniel Fintinariu
Daniel Fintinariu

Reputation: 2793

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

Upvotes: 1

Related Questions