Running Cucumber tests with Parameterized Junit?

373 views
Skip to first unread message

Janine Roe

unread,
Aug 30, 2015, 10:55:56 AM8/30/15
to Cukes
Is it possible to use junits @RunWith(Parameterized.class)?
I need to run our tests with different browser configurations (i.e. IE8, IE9, IE10, IE11, FF, Chrome).
I have built out our test automation framework around the ability to run them parameterized WebDriver browser capabilities.
However adding Cucumber into the mix, I don't see how to keep this in place as to run cucumber tests you need the 
@RunWith(Cucumber.class)
And according to junit, you can't have multiple @RunWith options.

Has anyone had this same problem and if so is there a solution to accomplish this.

Thanks in advance!

Kanchan Govila

unread,
Sep 15, 2015, 4:21:46 PM9/15/15
to Cukes
Hello Janine,

I am also facing the same issue..in addition to it i have to run the tests with different browser combi like at a time i want two browsers to be launched..

Did you get any solutions for the previous issue????do reply

Thanks in advance!

Roberto Lo Giacco

unread,
Sep 16, 2015, 5:07:47 AM9/16/15
to Cukes
This is getting back every now and then, may be I'll post something on my blog about this...
The solution we have adopted in my company is to run the tests multiple times, each time using a different browser. We switch the browser using Spring profiles, but a an environment property will do as well. We are using Maven Failsafe Plugin to run Cucumber, but if you run directly or in any other way it will do as well.

We have a few tests we know are not applicable to certain browsers, in that cases we use Cucumber tags to annotate the scenario to not be run on unsupported browsers (like @ie-fail for IE unsafe tests) and we have a separate set of stepdefs for mobile UI (desktop and mobile packages) with scenarios not applicable to one or the other tagged accordingly (@mobile-only @desktop-only)

So our runs are like

java JUnitWrapper -Dselenium.driver=Firefox -Dcucumber.tags=~@firefox-fail,~@mobile-only -Dglue=foo.bar.desktop.* // to run dekstop tests on firefox

java JUnitWrapper -Dselenium.driver=Chrome -Dcucumber.tags=~@chrome-fail,~@desktop-only -Dglue=foo.bar.mobile.* // to run mobile tests on chrome

Does it make sense? 

Roberto Lo Giacco

unread,
Sep 16, 2015, 5:15:44 AM9/16/15
to Cukes


Il giorno martedì 15 settembre 2015 22:21:46 UTC+2, Kanchan Govila ha scritto:
Hello Janine,

I am also facing the same issue..in addition to it i have to run the tests with different browser combi like at a time i want two browsers to be launched..

Did you get any solutions for the previous issue????do reply

Thanks in advance!

With regards to the two browsers I would question your testing approach... Are you testing the browsers themselves? If you are testing some code which involves the communication with a server I would separate the two parts as testing the two browsers together can get very tricky adding little or nothing to your tests value. 
Nevertheless the above is still applicable, but your executions will just multiply:

java JUnitWrapper -Dselenium.driver1=Firefox -Dselenium.driver2=Chrome // tests on firefox as first browser instance and chrome as second


I cannot imagine a scenario where this might make sense though... Even on a web chat I wouldn't go down this route. Your tests will be very brittle (as you have two browsers contending your machine resources) and you will have a very hard time to test the same browser combinations (Chrome-Chrome, Firefox-Firefox, etc...).

I would think about a different test strategy if I were you.....
Reply all
Reply to author
Forward
0 new messages