2013-10-09 24 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