2

I am using testNG and Appium to run mobile automation.Following are my codes:

package my.app.package;
public class TestDataProvider {

    @DataProvider(parallel=false)
    public static Object[][] GenericDataProviderWithNoCustomCapabilities() {
        return new Object[][] {
                {"", "Nexus_5_API_21_x86", "19", "C:\\Users\\me\\Desktop\\app.apk", "http://127.0.0.1:4723/wd/hub", ScreenOrientation.PORTRAIT},
                {"", "Nexus_5_API_21_x86", "20", "C:\\Users\\me\\Desktop\\app.apk", "http://127.0.0.1:4723/wd/hub", ScreenOrientation.LANDSCAPE}
                };
    }
}

In the test suite class:

public class SanityTestAndroid {

    private ScreenOrientation orientation;

    @Factory(dataProviderClass = my.app.package.TestDataProvider.class, dataProvider="GenericDataProviderWithNoCustomCapabilities")
    public SanityTestAndroid(String version, String avd, String platformVersion, String appPath, String targetPath, ScreenOrientation orientation) throws Exception {
        AndroidDriverFactory.create(version, avd, platformVersion, appPath, targetPath);
        this.orientation = orientation;
    }

    @Test()
    public void testLoginInLandscape() throws Exception {   
        if (orientation == ScreenOrientation.LANDSCAPE) {
        ...}
    ...}

And testNG.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="android automation" parallel="false">
  <test name="com.tribehr.qa.tests">
    <classes>
      <class name="my.app.package.test.SanityTestAndroid "/>
    </classes>
  </test>
</suite>

I have set all testNG parallel to false (as far as I know), but when running the test I still see it being run parallelly. I am not sure why, and what can I do to make it run twice in a queue (as two dataset are given).

jamesdeath123
  • 4,268
  • 11
  • 52
  • 93

3 Answers3

0

TestNG is executing tests sequentially by default. If they are executing concurrently, you must have a setting to do so.

Crazyjavahacking
  • 9,343
  • 2
  • 31
  • 40
0

You need to add group-by-instances="true" attribute to your test element in suite *.xml. In other case it doesn't work the way you expect.

user1058106
  • 530
  • 3
  • 12
  • I tried that but still not working as expected... – jamesdeath123 Feb 05 '15 at 15:34
  • @jamesdeath123, it's strange. Your code snippet seems to be okay. What IDE you use? what TestNG version? Are you sure that: 1) You have group-by-instances argument of your test set to true. 2) You run suite; not test or class when you run it from IDE. I mean mouse right click on your xml file-> Run As -> TestNG Suite. – user1058106 Feb 06 '15 at 10:20
  • Im using eclipse, and I do have things setup and run in the way you mentioned.. if I remove one data set and leave only one, it runs fine; if I run with two rows of data, Appium will give me error of cannot start new session, one session is already existing and this happens in the middle of the first data set run.. – jamesdeath123 Feb 06 '15 at 17:35
0

if your driver is initialized in @beforeTest method then drivers will open for all test at a time and then the tests of all classes will run sequentially

Anand
  • 1