2017-07-29 107 views
0

我是Visual Studio中的新成员。我使用SpecFlow使用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  | [email protected] | alpha | 
    | non-admin | [email protected] | 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

作为例子,围绕在Given步骤与''像这样<user>

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

将产生所期望的结果。可能需要识别正则表达式。

enter image description here

+0

谢谢丹尼尔。是的,它解决了这个问题。 –