I want to run feature files in a desired order or sequence, for example:
tags:"`@ProtractorScenario` or @CucumberScenario"
But cucumber scenario is getting executed first. Can someone guide me on this?
Note: Cucumber is executing scenario based on alphabetical order of feature file in folder
Also, in cases with more than 50+ feature files, what would be the best way to define sequencing of cucumber feature files?
In order to have reliable tests, your tests should be independent and not rely on the order they are run in. The reason being that your test shouldn't depend on the system being in a certain state, as this will lead to flaky tests. Each of your tests should set up the expected state (and teardown!), so they can be run independently.
Below is how protractor executes cucumber feature files:
specs
, save the absolute file path into an array, let's call itfeature_list
.Protractor generates a Cucumber CLI as below, and execute the CLI to hand over the running control cucumber:
./node_modules/bin/cucumber --require xxx --format xxx feature1,feature2,....featureN
feature1,feature2,....featureN calculated by
feature_list.join(',')
From above, we can learn the only opportunity to change the order is given an order-done
feature_list
to protractorspecs
.You can get a solution code from my github: spec.filter.js, which implements:
Guide to use
spec.filter.js
: