Picking tagged tests based on environment

12 views
Skip to first unread message

Mugil Paramasivam

unread,
May 9, 2017, 9:25:12 PM5/9/17
to Cukes
Hi,
I have a feature file with 20+ scenarios. 
I want to run all tests in qa environment and only few test in prod environment.
I have tagged the tests as @qa and @prod .
But how to I tell cucumber to run only @qa test if I pass "app.environment" variable as 'qa' and run only @prod tests if "app.environment" is set to 'prod'
Thanks

Eric Kessler

unread,
May 9, 2017, 10:53:50 PM5/9/17
to Cukes
You could make a Before hook for each of those tags and have that hook forcefully skip the test if the corresponding variable does not match. I don't know if there is an easy method for such a forced skip in all implementations of Cucumber (but Ruby does have one).

A better solution, however, would be to not tell Cucumber to run unnecessary tests in the first place. Run `cucumber -t ~@qa` or `cucumber -t ~@prod` (or whatever their equivalent is for your programming language of choice) as appropriate and have that decision be made by some other tool (e.g. your CI tool).


Eric K
Reply all
Reply to author
Forward
0 new messages