Reputation: 1
I have created a cucumber-spring project using a single EventFiringWebDriver spring bean for all the scenarios in each feature file. My tests are working fine and not opening a new driver per scenario reduces the total test time. Is this an acceptable practice? Thanks for your help!
Upvotes: 0
Views: 1017
Reputation: 5908
As standard practice, You should have driver management separate from test code, that should provide and manage driver session(s) depending on your run-time configuration of running parallel or sequential on single or multiple browsers/platforms.
In our case, we are using qaf with gherkin and qaf takes care of providing thread safe driver session to run scenarios in parallel or sequential in one or multiple browsers. We specifies that in xml configuration file which is standard test-ng configuration file. For example following configuration file runs scenarios in parallel in two browsers (both browsers parallel):
<suite name="AUT Test Automation" verbose="0" parallel="tests" thread-count="10">
<test name="Tests on ff" parallel="methods">
<parameter name="driver.name" value="firefoxDriver" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
<test name="Tests on chrome" parallel="methods">
<parameter name="driver.name" value="chromeDriver" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
</suite>
Configuration can be done depending on needs.
Upvotes: 1
Reputation: 25577
Best practice is to have one test per browser. This better isolates issues to a single run so if one script goes sideways, it's less likely to affect other scripts.
If you haven't already, look into parallel execution. That's your best bet for making things go faster. If you just add one more browser, you will cut your overall execution time in ~half... more browsers just makes it even faster.
Upvotes: 1