alex
alex

Reputation: 694

Testng: how to set thread-count number as launch parameter

I'm using testng to run tests in parallel. Xml file contains thread-count parameter.

<suite name="Lalala" parallel="tests" thread-count="3" preserve-order="true">

But I want to set the thread-count value as parameter when launching tests. Command line looks like

-ea -Dstagefile=stage -Dbrowser=chrome clean test

Is there some way to add thread-count to command line?

Upvotes: 2

Views: 3685

Answers (2)

tim-slifer
tim-slifer

Reputation: 1088

To my knowledge, the only way to set the thread count programmatically is on TestNG.setThreadCount() (Javadoc).

This would require you to write a runner class with a main method that instantiates TestNG and invokes configuration methods. You can then accept command line args for the parameter.

While valid, it's completely redundant to just using the baked in -threadcount arg as @mfulton26 has stated.

Upvotes: -1

mfulton26
mfulton26

Reputation: 31234

You can specify -threadcount on the command line (see Command Line Parameters under Running TestNG). You'll then want to omit thread-count="3" from your xml file so that you don't override the command line option.

Upvotes: 2

Related Questions