How to run cucumber features in specified order | Selenium Forum
M
Posted on 09/02/2016
Hi Ashish,

In cucumber, how to run features in sequence. Currently, I have two feature files named login.feature and createLead.feature.
And i want to run them in same order that is first login and then createLead. However, Cucumber always run createLead first and then login.

After googling the issue, if found that "Cucumber feature files are executed in alphabetical order by path and filename. The execution order is not based on tags."

Please help on this one. Following is the cucumberoptions i am using in my runner class:

@CucumberOptions(plugin={"html:output/cucumber-html-report","json:output/cucumber-json-report.json"}
, tags = {"@login,@createLead"}
, features={"src\\main\\resources\\com\\qtpselenium\\app\\salesforce\\testcases\\login.feature","src\\main\\resources\\com\\qtpselenium\\app\\salesforce\\testcases\\createLead.feature"})

M
Replied on 09/02/2016

take a look at this

http://stackoverflow.com/questions/18377292/cucumber-in-which-oder-the-feature-tags-are-followed-in-cucumber-script


M
Replied on 10/02/2016

Hi Ashish,

I tried all the things mentioned in the link that you have provided, but still cucumber is running the feature file in Alphabetical order.
Please let me know if there is any other way out.


M
Replied on 10/02/2016

send a screen shot how you tried.


M
Replied on 11/02/2016

Hi Ashish,

Screenshot attached...

Responsive image

M
Replied on 11/02/2016

send the project i'll try to run it.


M
Replied on 15/02/2016

I have attached the project, please try at your end...


M
Replied on 15/02/2016

do it like this.

Responsive image

M
Replied on 16/02/2016

Hi Ashish,

Thanks for the solution!

Also, is there any other way to achieve this?


M
Replied on 16/02/2016

no couldn't find any way else.