Search code examples
seleniumtestngtestng-dataprovider

Parallel execution with data provider


I am trying to run the test parallel using dataprovider. I have mentioned dataproviderthreadcount=3 in testng xml

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

Test methods:

@Test(dataProvider = "dp1", threadPoolSize=3,invocationCount=1)
public void Testsuitesample(String url, String add1, String add2){}

Result: 3 browser instances get opened and all three data is passing to only browser. Other browser's are still idle. Is it a way to resolve this?


Solution

  • You may need to set parallel to true in your data provider method like,

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

    Also, the invocation count should be equal or greater than the thread pool size.