黄瓜执行顺序-Ruby [英] Cucumber Order of Execution - Ruby

查看:98
本文介绍了黄瓜执行顺序-Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以指定黄瓜内部的执行顺序?例如,而不是运行黄瓜功能/foo/foo.feature功能/foo/bar.feature 使其按该顺序执行...我想运行 bundle exec黄瓜并以此顺序运行指定的顺序.

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.

我知道功能/场景应该相互独立,但是对于我正在运行的当前测试来说,这是不切实际的.如果没有官方方式"(似乎是这种情况),是否有人会推荐一个好的设计来实现这种功能?

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.

这篇关于黄瓜执行顺序-Ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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