黄瓜:每个功能都单独通过,但不能同时通过 [英] Cucumber: Each feature passes individually, but not together

查看:70
本文介绍了黄瓜:每个功能都单独通过,但不能同时通过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Rails 3.1应用程序,并且我有一组三个黄瓜功能文件。单独运行时,例如:

I am writing a Rails 3.1 app, and I have a set of three cucumber feature files. When run individually, as with:

cucumber features/quota.feature
-- or --
cucumber features/quota.feature:67  # specifying the specific individual test

...每个功能文件运行精细。但是,当所有这些一起运行时,例如:

...each feature file runs fine. However, when all run together, as with:

cucumber

...其中一项测试失败。奇怪的是,只有一个测试失败;该功能中的所有其他测试都通过了(很多都做类似的事情)。将该测试放在功能文件的哪个位置似乎并不重要;

...one of the tests fails. It's odd because only one test fails; all the other tests in the feature pass (and many of them do similar things). It doesn't seem to matter where in the feature file I place this test; it fails if it's the first test or way down there somewhere.

我不认为这可以是测试本身,因为它在单独运行甚至通过时都可以通过整个功能文件是单独运行的。似乎必须一起运行不同的功能部件,才能产生一定的效果。任何想法可能会发生什么?

I don't think it can be the test itself, because it passes when run individually or even when the whole feature file is run individually. It seems like it must be some effect related to running the different feature files together. Any ideas what might be going on?

推荐答案

看来您的方案之间存在耦合。您的失败方案假设系统处于某种状态。当方案单独运行时,系统处于此状态,因此方案通过。但是,当您运行所有方案时,以前运行的方案会更改此状态,因此会失败。

It looks like there is a coupling between your scenarios. Your failing scenario assumes that system is in some state. When scenarios run individually system is in this state and so scenario passes. But when you run all scenarios, scenarios that ran previously change this state and so it fails.

您应该通过使方案完全独立来解决此问题。任何情况下的工作都不应影响其他情况下的结果。 黄瓜书通过示例进行说明

You should solve it by making your scenarios completely independent. Work of any scenario shouldn't influence results of other scenarios. It's highly encouraged in Cucumber Book and Specification by Example.

这篇关于黄瓜:每个功能都单独通过,但不能同时通过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆