0

I want to run different feature files based and want to decide it at runtime, i.e via command line arguments.

Everytime I uncomment the file and then run the test. Tried working with cucumber tags and did not get around it.

specs: [

//   'features/subscription/create.feature'
// './features/payment/create.feature'

],

Is there any simple way to do this?

Rakesh
  • 104
  • 1
  • 11
  • Can you show us the command you are using to run your tests? I usually say stay away from absolute paths when running tests and instead use tags. You said tags are not working but you don't say why – Ray Jan 29 '19 at 00:59

1 Answers1

1

There are two ways as far as i know:

  1. Defining suites with required feature files and pass the suite name as parameter to WDIO test.

Detailed explanation on suites: https://webdriver.io/docs/organizingsuites.html NOTE: In case if you are using npm test for starting the test, then use npm test -- --suite login to pick a suite.(this is not mentioned in the file).

  1. You can directly pass in the features through command line as like below:

In you wdio.conf.js file write the below lines above the exports.config and parameter the spec value.

var features = process.env.FEATURE || './features/**/*.feature';
var featureArray = features.split(',');
exports.config = { .... spec: featureArray, ....} //skipped others

now while triggering the test use the command like below: FEATURE='./features/test.feature,./features/test1.feature' npm test

So when the execution begins, features will receive the string and we converted that to array and passing as parameter to spec.

Hope this helps.