testng icon indicating copy to clipboard operation
testng copied to clipboard

Incorrect Thread count added to test context

Open sukhjinder-sdei opened this issue 8 years ago • 1 comments

While generating suite programmatically incorrect thread count added into test context

TestNG Version

6.14.3

Expected behavior

thread-count="0"

Actual behavior

thread-count="5"

Is the issue reproductible on runner?

XmlSuite suite = new XmlSuite();
suite.setName("A Test Suite");
List excludeGroups = new ArrayList<String>();
excludeGroups.add("broken");
XmlTest test = new XmlTest(suite);
test.setName("ABC-Tests");
test.setPreserveOrder(true);
test.setExcludedGroups(excludeGroups);
test.setParallel(XmlSuite.ParallelMode.NONE);
test.setThreadCount(0);
List<XmlClass> xmlClasses = new ArrayList<XmlClass>();
String strClass = packageName + "." + "abc";
XmlClass xmlClass = new XmlClass(strClass);
xmlClasses.add(xmlClass);

test.setXmlClasses(xmlClasses);

suite.toXml().toString()

<test thread-count="5" name="ABC-Tests"> <groups> <run> <exclude name="broken"/> </run> </groups> <classes> <class name="abc.testclass"/> </classes> </test> <!-- CleanUp-Tests -->

  • [x] Maven
  • [x] IntelliJ

Test case sample

Please, share the test case (as small as possible) which shows the issue

sukhjinder-sdei avatar Jun 21 '18 07:06 sukhjinder-sdei

At the <test> level only when a value greater than zero if set, would be taken as a valid value for the thread-count at the <test>, else we default back to the value set at the <suite> level (which is by default 5).

Try setting a value greater than zero via org.testng.xml.XmlTest#setThreadCount and you should see it being reflected in the xml representation. Also if you think about it, what do you gain by setting a thread pool size of zero (no threads) ?

Closing this issue with resolution as TestNG is working as designed.

krmahadevan avatar Jun 21 '18 12:06 krmahadevan