Maybe you didn't passed the DataProvider
to your constructor.
You need to do something like this in order to run the tests in parallel:
TestNG config:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestNG-OddCheckerTest" verbose="1" parallel="methods" thread-count="10" data-provider-thread-count="10">
<test name="OddCheckerTest">
<classes>
<class name="com.mypackage.test.OddCheckerTest" />
</classes>
</test>
</suite>
TestClass:
package com.mypackage.test;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
@Test
public class OddCheckerTest {
private long number;
@Factory(dataProvider = "numberList")
public OddCheckerTest(long number) {
this.number = number;
}
@DataProvider(name = "numberList", parallel = true)
public static Object[][] getNumber() {
return new Object[][]{
{1}, {3}, {5}, {77}, {111}, {123}, {287}, {305}, {505}, {607}, {709}, {803}, {805}
};
}
@Test
public void testForOdd() throws InterruptedException {
System.out.println(Thread.currentThread().getName() + ": checking that [ " + number + " ] it's odd!");
Thread.sleep(1000);
Assert.assertTrue(number % 2 == 1, "Number [" + number + "] is not odd!");
}
}
Output: