I'm trying to run my automation suite (implemented using Selenium Webdriver (Java) + TestNG + Maven) in parallel on different Android devices. Here's my code in xml:
<test name="Test1">
<parameter name="deviceName_" value="simulator1"/>
<parameter name="port_" value="4723"/>
<classes>
<class name="tests.TotoTests">
<methods>
<include name=".*" />
</methods>
</class>
</classes>
</test>
<!--test name="Test2">
<parameter name="deviceName_" value="simulator2"/>
<parameter name="port_" value="4725"/>
<classes>
<class name="tests.TotoTests">
<methods>
<include name=".*" />
</methods>
</class>
</classes>
</test-->
In class TotoTests, I have 20 tests. Each of them has the annotation @Test. When I run the xml, two devices run the class TotoTests in parallel. So my device1(simulator1) run 20 tests, and my device2 (simulator2) run 20 tests, too.
But what I want is, the simulator1 run the first test in TotoTests, and the simulator2 begins to run the second test in TotoTests. When one device has finished, it will run the third test in TotoTests. And then when one of the device finished, it will run the 4th test. So to run 20 tests, I will need only half time. Because each device will run only 10 tests, or 9 tests, or 11 tests....But not 20 tests.
How can I do this?