Testing with Cucumber and Selenium:How can i break the sequence of feature file and run in random sequence

978 views Asked by At

I have tried many option but any of them not work as i need. I have created some feature file as i required time by time. so i have a disorder feature file. I want to run the feature file as i wanted. like.

  1. fil1.feature
  2. fil2.feature
  3. fil3.feature
  4. fil4.feature so i want to run in this sequence : file3.feature->fil4.feature->fil1.feature.

I have tried @tag, @feature in junit test runner option but its maintain the sequence its run only 3,4 but can't run 1.

So can you tell me how to run feature file randomly???

2

There are 2 answers

1
Grasshopper On

Cucumber picks up the feature files in alphabetic order from the folder given in the features parameter of the CucumberOptions. So one options would be to rename your feature files alphabetically in the order you want.

After the feature files in the initial folder are read, then the sub folders in the location are picked up alphabetically and the feature files inside them are read. So you can place the file you want to be used later into a sub-folder.

Saying all this, it is not a very good idea to have any dependency between tests which requires a sequence to be maintained.

1
Holy On

I got the same stop. Have you solved this problem?

I did some test, use --tags @XXX to controll the sequence is useless, it's just action on different scenarios in a feature file.

so far, I have to do it like this cucumber features/c.feature features/a.feature features/b.feature I think this is a little bit better than rename feature files.

But you may say that: "If there is a lot of feature files......" In my project(ROR), I assigned the statement to ./config/cucumber.yml

In cucumber.yml I define a profile, test_dev: features/c.feature features/a.feature features/b.feature after that, I just to use cucumber -p test_dev and the feature files execute in order.

If you have a butter way, please share with us.