2012-04-04 58 views
0

早上好。將SpecFlow功能連接到步驟。鏈接不斷打破

我遇到了SpecFlow的問題,我無法弄清楚如何解決它。將不勝感激任何幫助。所以......

讓我們舉一個簡單的SpecFlow特點:

Given the JoeDoe user is associated to an existing staff account with the following information 
    | Field  | Value   | 
    | First Name | Joe   | 
    | Last Name | Doe   | 

它連接到下面的步驟:

 [Given(@"the JoeDoe user is associated to an existing staff account with the following information")] 
     public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(Table table) 
     { 
     ...logic 
     } 

但是,一旦我改變步接受來自特徵參數,如以下內容:

 [Given(@"the (*.) user is associated to an existing staff account with the following information")] 
     public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(string userName, Table table) 
     { 
     ...logic 
     } 

該功能間鏈接斷開。從上如果我按F12(或者轉到步驟定義)從內featere Visual Studio中告訴我,這一點是沒有對準步驟和:

「無匹配的步驟綁定找到了這一步你想將綁定框架複製到剪貼板?「

當然,測試場景不運行。

這是怎麼回事?我似乎正在做一切正確的事情。

回答

2

你試過:

[Given(@"the (.*) user is associated to an existing staff account with the following information")] 
    public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(string userName, Table table) 
    { 
    ...logic 
    } 

應該(.*),而不是(*.)

+0

謝謝您的回覆。對不起,這只是我提供示例時的一個錯字。在我的代碼中,正則表達式的值是正確的。我將修改OP。 – Shenaniganz 2012-04-04 19:14:41

+0

其實我會將它反轉爲*。這裏在OP ...誰知道,有一天可能對某個人有用。但是,對我來說,這不是問題。 – Shenaniganz 2012-04-04 19:16:21

+0

雖然在我的情況下不是問題,但這可能是其他人的另一個解決方案:http://groups.google.com/group/specflow/browse_thread/thread/f66f679d34edfeb2 – Shenaniganz 2012-04-04 19:18:08