Reputation: 1
I have set up a parallel execution of tests in cucumber for running parallel tests on available Android devices. Below are the steps I have performed. And I have set up by referring the cucumber documentation https://cucumber.io/docs/guides/parallel-execution/#testng
Step 1 : Extended AbstractTestNGCucumberTests class in my TestRunner class and added below method
@Override
@DataProvider(parallel = true)
public Object[][] scenarios() {
return super.scenarios();
}
Step 2: In pom.xml i have added below parameters inside configuration tag
<parallel>methods</parallel>
<threadCount>4</threadCount>
For example if there are 5 test cases to run, When I tried to execute from the pom.xml/TestRunner class file. 4 Devices are getting launched, only the very first device executes one test case. Rest of them are failing by throwing SessionNotCreatedException and the execution halts.
Can any one please let me know the resolution at the earliest ?
Thanks much in advance !
Please let me know if something is not clear from my above points?
Upvotes: 0
Views: 1185
Reputation: 1
throwing SessionNotCreatedException
This is because you are using the same user for different threads. use different users for parallel testing
try this and confirm
Upvotes: 0
Reputation: 1038
You can implement concurrent testing in different ways. I suggest to follow this way because you use Maven, TestNG and Cucumber. You can create TestNG xml runner file with parallelism configurations and add you launchers to the file (classes paths).
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
<suite name="My suite" parallel="classes" thread-count="5">
<test name="Nopackage" >
<classes>
<class name="NoPackageTest" />
</classes>
</test>
<test name="Regression1">
<classes>
<class name="test.sample.ParameterSample"/>
<class name="test.sample.ParameterTest"/>
</classes>
</test>
</suite>
Here you can find more details about TestNG parallelism and here about xml runners. The concept is to create a class that extends abstract testng runner then to add it to XML file as package path then to run the xml file as testng. In the future you can execute Maven command to run the file with parameters if needed and it useful for CI/CD tools
Upvotes: 1