user1596371
user1596371

Reputation:

Test parallelism with IntelliJ and TestNG

I'm attempting to run some TestNG tests in parallel but don't have access to a testng.xml as IntelliJ builds it on the fly. I've tried adding parameters such as 'parallel=methods' to the run configuration but this doesn't appear to be making any difference.

How can I make TestNG run in parallel from IntelliJ without resorting to having to build my own testng.xml file?

Upvotes: 12

Views: 8861

Answers (5)

user8715994
user8715994

Reputation:

Another option is to use a 'Create TestNG XML' plugin. It instantly generates a testng.xml file so you don't have to customise one. Once installed, right click on your module name and you will see the 'Create TestNG XML' option.

Upvotes: 0

Justin Gottshall
Justin Gottshall

Reputation: 131

I managed to get test methods to run in parallel without defining a custom testng.xml for each test by adding "-parallel methods -threadcount 20 -dataproviderthreadcount 20" in the "Test runner params" field of a TestNG run configuration.

Upvotes: 11

RocketRaccoon
RocketRaccoon

Reputation: 2599

The best option for Intellij IDEA is to create additional testng.xml or you may run test from command line.

Upvotes: 0

thekevinmonster
thekevinmonster

Reputation: 387

It appears that you would be able to use the JDK Settings tab to specify "vm parameters", and then specify the parameters like so: -parallel methods -threadcount 2

However, IntelliJ actually creates an XML file and then uses that when running TestNG. That XML file has parallel="none" inside of it. As a result, the XML configuration 'wins' and you do not get the parallelization you are looking for.

There doesn't appear to be an easy way to adjust the contents of that default XML file, at least in terms of the parallelization options. You may just be stuck with creating XML suites yourself.

Upvotes: 1

Rick
Rick

Reputation: 446

You can't set this up with annotations. It must be configured in the XML. You need to set up an XML template. In eclipse it would be windows -> preferences -> testNG Template XML File.

Use an XML file that has all your parallel and usual optins and when you run as testNG it will replace only the section, while maintaining your other settings.

Upvotes: -1

Related Questions