Reputation: 2320
I would like to run my integration tests in parallel so that: * each test method is run by a different jvm * and each uses a single thread
After reading the surefire docs I thought of using:
mvn test -DforkCount=2 -DreuseForks=false -Dparallel=methods -DthreadCount=1
but my tests appear to fail (of course, running just mvn test
that runs them sequentially doesn't fail)
Any idea how I can achieve multi process single threaded?
Upvotes: 2
Views: 1958
Reputation: 7620
Surefire plugin executes different classes in forkCount
separate JVM processes, each JVM using threadCount
threads and if parallel=methods
then each method will be given a thread. In other words each fork is given a class, each method is given a thread. You cannot map between methods and forks.
From the Surefire's page, paragraph on combining forkCount and parallel:
However, you can use parallel=methods: classes are executed in forkCount concurrent processes, each of the processes can then use threadCount threads to execute the methods of one class in parallel.
TestNG has following annotation in case it could help:
@Test(threadPoolSize = 3, invocationCount = 6, timeOut = 1000)
EDIT: having just read the comments:
You have to make your unit tests correct first, and then speed the execution up.
Upvotes: 1