2012-12-11 40 views
1

我創建2個簡單的場景如下:黃瓜:如何避免模棱兩可的步驟?

Scenario: 1 
Given I am on the homepage 
When I click the expand arrow 
Then the drawer is expanded 

Scenario: 2 
Given the drawer is expanded 

,問題是,那麼第一個場景,並給出了第二的是由黃瓜這樣寫的:

Then /^the drawer is expanded$/ do 
Given /^the drawer is expanded$/ do 

和那麼我會收到一條錯誤消息:

Ambiguous match of "the drawer is expanded" 

當我嘗試運行它時。

有沒有辦法避免這個模棱兩可的步驟?

非常感謝!

回答

0

最好重寫這些步驟,以便兩個步驟不同。

一種方式做這將是跟隨在他的博客帖子Rewriting Ambiguous Cucumber Steps帕特馬多克斯的建議,並改寫第二個方案如下:

Scenario 2 
Given that the drawer is expanded 
+0

啊,好主意普拉卡什!非常感謝您的建議...... – mickael