生成不正确方法的场景大纲的SpecFlow步骤生成

时间:2017-07-29 07:21:38

标签: visual-studio bdd specflow gherkin

我是Visual Studio的新手。我正在使用Visual Studio 2015和SpecFlow。以下是功能文件:

@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  |

当我生成步骤定义时,我期待参数代替变量,而不是生成如下方法:

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

我反而期待一种方法:

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

我错过了什么?

1 个答案:

答案 0 :(得分:1)

例如,<user>步骤中的Given围绕'',{/ p>}

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

将生成所需的结果。为了识别正则表达式,可能需要它。

enter image description here