如果我們在煙霧測試類型的情況下使用小黃瓜並且我們只需要使用UI來確保數據庫中存在某些東西,那麼呢?
Scenario: I need to create one (and only one) Box before I run the rest of my smoke tests
Given I login as Admin
When I am on the Box list Page
Then the test passes if the Box named "QA SmokeTest" exists
When I click the Add New Box Button
And enter the details for a New Box
And press Save New Box
Then the test passes if the Box named "QA SmokeTest" exists
重新使用相同的Then
步驟兩次基本上是一個if-else的,這將確保我的盒子存在,這樣我可以在煙霧測試套件,需要一個盒子運行我的其他測試。
但是,這是依賴於能夠阻止腳本執行的測試跑步或做喜歡的事,多餘的:
ScenarioContext.Current["TestPassed"] = true;
,然後在每個步驟
if(ScenarioContext.Current.Get<bool>("TestPassed")) return;
沒有,在你的榜樣,你正在一箇中描述兩種情況。他們應該分開。 – jmccure