How to order feature files in Cucumber test suite?
Solution 1
In cucumber 4.2.0 added cli option --order
, see changelog and this example.
Solution 2
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
.
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.txt
and it has the following contents:
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)
Solution 3
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
TT_
Updated on November 12, 2021Comments
-
TT_ over 2 years
Currently, I have found that cucumber test suite runs the feature files alphabetically.
Please let me know if there is any option/configuration that I might be missing. Thanks.