2017-07-29 105 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

謝謝丹尼爾。是的,它解決了這個問題。 –