【问题标题】:Get Status from Scenario with Cucumber 2.0.0使用 Cucumber 2.0.0 从场景中获取状态
【发布时间】:2016-10-04 02:34:46
【问题描述】:

好像不能再用了

scenario.status 

在 Cucumber 2.0.0 中确定场景的状态(通过、失败、未定义、跳过)。看起来可以查看场景是通过还是失败,但我也希望查看何时未定义或跳过步骤。

以前,在我的代码中,我会将结果写入场景的 After 挂钩中的数据库,如下所示:

After do |scenario|
  @controller.post_results(scenario)
end

在发布结果中,我会调用scenario.status 来获取状态。

Cucumber 2.0.0 不能再这样做了吗?如果是,新方法是什么?

【问题讨论】:

    标签: ruby cucumber


    【解决方案1】:

    您需要使用 Hooks.rb 来获取场景的状态。

    你可以使用

    if scenario.failed?
        todo...
    end
    

    scenario.status
    

    在 hooks.rb 中。

    在此处查找更多详细信息:https://github.com/cucumber/cucumber/wiki/Hooks

    【讨论】:

    • 谢谢。我应该发布的,但是在我最初发布此内容时,api 有所不同。他们已经在最新版本的黄瓜中添加了状态方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多