Below is how protractor executes cucumber feature files:
- Protractor finds out all feature files specified in
specs
, save the absolute file path into an array, let's call it feature_list
.
- Protractor starts a session (start a browser instance)
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 protractor specs
.
Note: every member of the feature_list
should be absolute/relative
path of single feature file. folder
and wildcard
are not recommended to appear in the path.
You can get a solution code from my github: spec.filter.js, which implements:
- filter feature file by cucumberOpts.tags
- order filter result of above step 1 by priority
Guide to use spec.filter.js
:
// protractor conf file
const specFilter = require('./spec.filter.js');
var config = {
seleniumAddress: 'xxxxx',
capabilities:'xxxx',
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
ignoreUncaughtExceptions: true,
specs: [
'./aa/**/*.feature',
'./bb/**/*.feature'
],
cucumberOpts: {
require: [
'xxx'
],
priorities: {
// feature has tag @SPGC-21542 or @SPGC-21944 or @SPGC-21946
// will has priority 1
'1': ['@SPGC-21542 or @SPGC-21944', '@SPGC-21946'],
// feature has tag @SPGC-22055 will has priority 2,
// feature has heighest priority will put ahead at
// the `specs` list and get executed firstly.
'2': ['@SPGC-22055']
}
tags: ""
}
....
};
exports.config = specFilter(config);