2013-10-09 23 views
2

是否有方法從鉤子文件內部啓動一個方案。在After hook中,我抓取失敗的場景的行,以及場景所在的文件或功能,並對其進行格式化,以便我可以在cmd中運行該行,並且只運行失敗的場景。從鉤子文件運行黃瓜測試

例如:功能\ homepage.feature:8環境= 'http://stage.homepage.local/'

現在我需要幫助的上一個失敗的情況下

After() do |scenario| 
    if scenario.failed? 
    #code here w/ cucumber features\homepage.feature:8 environment='http://stage.homepage.local/' 
    end 
end 

機後可這甚至可以做到運行此?

回答

0

我們可以從掛鉤文件運行場景。系統是用於在控制檯中執行給定命令的關鍵字。

試試下面的代碼

後()做|場景|

if scenario.failed?

run_cmd = "cucumber features\homepage.feature:8 environment='http://stage.homepage.local/'" 

system run_cmd