简体   繁体   English

黄瓜执行顺序-Ruby

[英]Cucumber Order of Execution - Ruby

Is there a way to specify order of execution inside cucumber? 有没有一种方法可以指定黄瓜内部的执行顺序? For example, rather than running cucumber feature/foo/foo.feature feature/foo/bar.feature to have those execute in that order... I want to run bundle exec cucumber and run in that specified order. 例如,而不是运行cucumber feature/foo/foo.feature feature/foo/bar.feature来使它们按该顺序执行...我想运行bundle exec cucumber并按指定的顺序运行。

I know that features/scenarios should be independent of each other but for the current tests I'm running it's not practical. 我知道功能/场景应该彼此独立,但是对于我正在运行的当前测试来说,这是不切实际的。 If there is no "official way" (which seems to be the case) does anyone recommend a good design to implement such functionality? 如果没有“官方方式”(似乎是这种情况),是否有人会推荐一个好的设计来实现这种功能?

Copying my own answer from here : 这里复制我自己的答案:

As mentioned here, Cucumber scenarios should not be dependent on each other. 如此处所述,黄瓜方案不应相互依赖。

According to the Cucumber best practices, there shouldn't be any sort of coupling between scenarios. 根据黄瓜的最佳实践,场景之间不应该存在任何形式的耦合。 Or in other words, there should be no state that persists between scenarios. 换句话说,场景之间不应存在任何状态。

Just as an example why this is a bad practice consider a case when one scenario step adds a record to a database, while the subsequent scenarios depend on the existence of that record. 举一个为什么这是一个不好的做法的例子,考虑一个场景步骤将一个记录添加到数据库,而随后的场景则取决于该记录的存在。 This may work, but will create a problem if the order in which scenarios run changes, or they are run in parallel. 这可能有效,但是如果方案运行的顺序更改或并行运行,则会产生问题。

Try to review your approach and see how can you define your scenarios differently to avoid coupling. 尝试检查您的方法,看看如何才能以不同的方式定义方案以避免耦合。 Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM