java 如何在 Cucumber 测试套件中订购特征文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38781629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:45:58  来源:igfitidea点击:

How to order feature files in Cucumber test suite?

javaseleniumselenium-webdrivercucumberbdd

提问by TT_

Currently, I have found that cucumber test suite runs the feature files alphabetically.

目前,我发现 Cucumber 测试套件按字母顺序运行功能文件。

Please let me know if there is any option/configuration that I might be missing. Thanks.

如果有任何我可能遗漏的选项/配置,请告诉我。谢谢。

回答by

Cucumber features/scenarios are run in Alphabetical order by feature file name.

Cucumber 功能/场景按功能文件名按字母顺序运行。

However, if you specifically specify features, they should be run in the order as declared. For example:

但是,如果您特别指定功能,则应按声明的顺序运行它们。例如:

@Cucumber.Options(features={"automatedTestingServices.feature", "smoketest.feature"})

回答by LudmilaN

In cucumber 4.2.0 added cli option --order, see changelogand this example.

在 Cucumber 4.2.0 中添加了 cli 选项--order,请参阅更改日志此示例

回答by zarak

You can force cucumber to run the feature files in the order that you pass the filenames as arguments. For example,

您可以强制黄瓜按照将文件名作为参数传递的顺序运行功能文件。例如,

$ cucumber file3.feature file2.feature file1.feature

will run the files in the order file3.feature, file2.feature, file1.feature.

将按顺序运行文件file3.feature, file2.feature, file1.feature

You could also create a text file with the names of the feature files in the order that you want, with each name on its own line. For example, suppose the file is named feature_order.txtand it has the following contents:

您还可以创建一个文本文件,其中包含您想要的功能文件的名称,每个名称占一行。例如,假设该文件已命名feature_order.txt并且具有以下内容:

file3.feature
file2.feature
file1.feature

You can then run the following command to run the files in the above order:

然后,您可以运行以下命令以按上述顺序运行文件:

$ cucumber $(cat feature_order.txt)

回答by cecil tom

However, if you specifically specify features, they should be run in the order as declared. For example:

但是,如果您特别指定功能,则应按声明的顺序运行它们。例如:

@Cucumber.Options(features={"automatedTestingServices.feature", "smoketest.feature"})

The above one is still in the alphabetical Order. So it wont make any difference

上面的还是按字母顺序排列的。所以它不会有任何区别