0
是否有任何簡單的方法在黃瓜上將步驟標記爲失敗,以便在黃瓜中將場景標記爲失敗?如何使步驟定義文件中的步驟失敗,以便在黃瓜 - 水豚環境中自動將情景標記爲失敗?
我在使用Ruby語言編寫我的步驟定義文件的一個代碼:
SECONDS_TO_SLEEP = 5
MAX_NUM_ITERATIONS = 3
Given(/^The TREC UI is running$/) do
elapsedTime = 1
currentAttempts = 0
while currentAttempts <= MAX_NUM_ITERATIONS
begin
visit "http://sut:8080/myPage"
expect(page).to have_content("Welcome to My Page")
totalTime = elapsedTime + currentAttempts * SECONDS_TO_SLEEP
puts "It took #{totalTime} seconds for TREC UI to come up."
break
rescue
currentAttempts += 1
sleep SECONDS_TO_SLEEP
if currentAttempts <= MAX_NUM_ITERATIONS
puts "Waiting for web server to start."
else
raise "Web server failed to start."
end
end
end
end
當我跑我的特徵文件,我得到了這個輸出 Output_Snapshot
我不明白爲什麼在「Web服務器無法啓動」行之後,是否在輸出中顯示這些行?
有沒有其他簡單的方法來失敗步驟定義文件中的步驟?