黄瓜:背景失败仍然以代码0退出

时间:2011-12-19 10:04:08

标签: ruby cucumber exit-code scenarios

我想知道什么,当背景失败时,黄瓜会返回退出代码0(据我所知,这意味着“确定”)。

现在失败的步骤可能不应该在背景中(最好在'之前'钩子我猜...)。但有人知道它退回此退出代码的理念是什么? 这是一个错误还是一个功能?

附录: 一个更具体的例子: 让我们说这段代码通过了:

 Feature: Figuring out how Cucumber works

 As a developer
 I want to find out why cuccies fail, but my build doesnt
 In order to have more confidence in my build

 Background: logging in into the system
   Given I am logged in

 Scenario: creating a new test set
   When I do something
   Then I should see "you've done something"

返回退出代码0。 让它失败:

 Background: logging in into the system
   Given I am logged in

 Scenario: creating a new test set
   Then I should see "there's no way you see this"
   When I do something
   Then I should see "you've done something"

输出显示失败的步骤,并返回退出代码1 当我将失败的步骤移动到背景时:

 Background: logging in into the system
   Given I am logged in
   Then I should see "there's no way you see this"

 Scenario: creating a new test set
   When I do something
   Then I should see "you've done something"

输出仍显示失败,但返回时退出代码为0

2 个答案:

答案 0 :(得分:5)

我已经问过Cucumber的人(他们的邮件列表)并且他们同意了它的错误

http://groups.google.com/group/cukes/browse_thread/thread/e56699f0fabfc75f

答案 1 :(得分:1)

背景真的像之前一样,唯一不同的是,它是在之前运行的。并且由于您正在使用Background / Before(一般情况下)为您的场景设置先决条件,如果测试过程失败,错误代码与0建议不同,那将是非常有用的,因为您在你的先决条件中犯了一个错误。

所以我的猜测是,虽然我不能确定,这是一个'特征'而且非常有意。