2

我想知道一些事情,当背景失败时,黄瓜会返回退出代码 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

4

2 回答 2

5

我问过黄瓜人(他们的邮件列表),他们同意这是一个错误

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

于 2011-12-22T07:13:04.530 回答
1

背景真的很像 Before,唯一的区别是它在 Before 之后运行。并且由于您正在使用 Background/Before(通常)为您的场景设置先决条件,如果测试过程失败,这将不是很有帮助,与 0 不同的错误代码会暗示,只是因为您在您的先决条件中犯了一个错误。

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

于 2011-12-19T14:50:59.937 回答