Not able to run more than 10 Tests in parallel via TestNG Dataprovider

942 views Asked by At

Hi i have designed a selenium test to run in parallel (25)

@Test(dataProvider = "getData" )
public void multiUserTest(String url, String username, String password)
        throws InterruptedException, IOException, FindFailed {

    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setBrowserName(prop.getProperty("browserName"));
    capabilities.setPlatform(Platform.WINDOWS);
    RemoteWebDriver driver = new RemoteWebDriver(new URL(prop.getProperty("url")), capabilities);

    WebDriverWait wait = new WebDriverWait(driver, 720); // 12 minutes wait.
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);

    try {
        driver.get(url);
        driver.findElement(By.xpath(prop.getProperty("username"))).sendKeys(username);
        driver.findElement(By.xpath(prop.getProperty("password"))).sendKeys(password);
        driver.findElement(By.xpath(prop.getProperty("signin"))).click();
        }catch (Exception e) {
        e.printStackTrace();
    }

My data provider

@DataProvider(parallel = true)
public Object[][] getData() {

    Object data[][] = new Object[25][3];
    // row 1
    data[0][0] = "http:XXXX/login.html";
    data[0][1] = "[email protected]";
    data[0][2] = "XX@123";

    // row 2
    data[1][0] = "http:XXXX/login.html";
    data[1][1] = "[email protected]";
    data[1][2] = "XX@123";
    ..........


    // row 25
    data[24][0] = "http:XXXX/login.html";
    data[24][1] = "[email protected]";
    data[24][2] = "XX@123";

and my xml file is

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="methods"  thread-count="1" data-provider-thread-count="25">
  <test name="Test">
    <classes>
      <class name="XXX.MultiUserGuiTest"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

Now when i run my above test its running 10 tests at one go and after 10th test has finished then next 10 starts execution which is followed by 5 but i want to run my test where 25 should start execution at once

Just for reference i am adding a screenshot of my ec2 instances. There are 25 chrome, up and running also please have a look at mouse hover above chrome browserenter image description here

2

There are 2 answers

0
Rajnish Kumar On

Hi we have figured out a way through which we were able to run our 25 test in parallel ** But i don't think this is a standard way of doing this **. Please provide your feedback or a better way of doing above scenario.

Solution Instead of using data form data provider we have removed data provider completely and instead we are calling parameters form testng.xml file as Parameters by using

  @Parameters({"param 1","param 2","param 3","and so on"}) in our test

and now i can see my 25 nodes active at same time and perform all actions successfully.

0
Andrey On

To resolve the trouble:

@BeforeClass
    public void setupClassName(ITestContext context) {
        context.getCurrentXmlTest().getSuite().setDataProviderThreadCount(100);
        context.getCurrentXmlTest().getSuite().setPreserveOrder(false);
    }