Hi,
How can i run same Test case parallel on iOS and Android device. is that possible?
Could some one help on this.
Thanks in advance.
Hi,
How can i run same Test case parallel on iOS and Android device. is that possible?
Could some one help on this.
Thanks in advance.
You can run the same test case in parallel but there are a few things you need to take into consideration:
Thanks nivi,
for great solution.
I am using Eclipse with Testng.
Could you please share any snippet which you have that works.
That would be appreciated.
Thanks in Advance
Hi @sudhakar
Let’s assume that your test classes are named:
AndroidDemoTest.java
And
IOSDemoTest.java
Your testng.xml should look like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests">
<test name="TestIOS">
<parameter name="deviceQuery" value="@os='ios'"/>
<classes>
<class name="IOSDemoTest"/>
</classes>
</test> <!-- Test -->
<test name="TestAndroid">
<parameter name="deviceQuery" value="@os='android'"/>
<classes>
<class name="AndroidDemoTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
If you want a dry run (without actually running any tests on devices), you can run the following classes:
Android:
public class AndroidDemoTest {
protected AndroidDriver<AndroidElement> driver = null;
@BeforeMethod
@Parameters("deviceQuery")
public void setUp(@Optional("@os='android'") String deviceQuery) throws Exception{
System.out.println("Before: " + deviceQuery);
}
@Test
public void test(){
System.out.println("Running Android Test!");
}
@AfterMethod
public void tearDown(){
System.out.println("Quit!");
}
}
iOS:
public class IOSDemoTest {
protected IOSDriver<IOSElement> driver = null;
@BeforeMethod
@Parameters("deviceQuery")
public void setUp(@Optional("@os='ios'") String deviceQuery) throws Exception{
System.out.println("Before: " + deviceQuery);
}
@Test
public void test(){
System.out.println("Running iOS Test!");
}
@AfterMethod
public void tearDown(){
System.out.println("Quit!");
}
}