Rakesh
Rakesh

Reputation: 104

Choosing spec feature file in wdio at runtime

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?

Upvotes: 0

Views: 1650

Answers (1)

Naveen Thiyagarajan
Naveen Thiyagarajan

Reputation: 588

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.

Upvotes: 1

Related Questions