I'm trying to use JUnit5 and Surefire to run tests on parallel threads.
I have a test that will just run multiple test methods and print out the thread name, to check that the test methods are on different threads.
In my POM I use the recommended versions of all junit and surefire packages and dependencies.
If I run mvn clean test the tests methods run, but they all run sequentially on the main thread.
If I run mvn clean surefire:test the test does not run at all.
In issue #1341 the fix was to use junit-platform-surefire-provider 1.2.0-SNAPSHOT. I'm using the released 1.2.0 version from april 2018 and it's still not working. There is no information on that issue about whether the tests are actually running parallelised.
I included reproduction code in this gist: https://gist.github.com/jennyowen/563dbf93315e357bdf9e0bb2e098600b
Apache Maven 3.3.9
Java openjdk8
maven-surefire-plugin 2.21.0
junit-platform-surefire-provider 1.2.0
junit-jupiter-engine 5.2.0
junit-jupiter-api 5.2.0
#809 #1341
<parallel/> is currently not supported, only <forkCount/> works. However there's a dependency issue, so you also need to add an additional dependency to make Surefire happy (see https://github.com/junit-team/junit5/issues/801#issuecomment-380481871). Please note that we're currently handing over the provider to the Surefire project: https://github.com/apache/maven-surefire/pull/184.
Closing this issue -- please report new issues at https://maven.apache.org/surefire/issue-tracking.html
Jupiter 5.3 will support parallel test execution as an opt-in feature. See https://junit.org/junit5/docs/snapshot/user-guide/#writing-tests-parallel-execution for details.
Could you provide at least one example? Because I was not able to run tests in parallel.
Described here https://stackoverflow.com/questions/51308145/any-way-to-run-junit5-tests-in-parallel
@13Dima13 To use the new experimental feature, just remove all Maven config and add a src/test/resources/junit-platform.properties to your project that looks similar to this:
@marcphilipp : I see the still scripts are running in Parallel even after I removed junit-platform.properties from resource folder.
I had challenge of running UI automation scripts in parallel and i followed your steps and it worked awesome but after removing also i still see that scripts are running in parallel on my Jenkins slave machine but when i build the project on my local machine scripts are running sequentially as expected. What could be the reason for this behavior on jenkins slave machine.
@BalurQA I'm not sure. Are you running your tests in a different way on Jenkins? Is the file still around in its workspace?
Most helpful comment
@13Dima13 To use the new experimental feature, just remove all Maven config and add a
src/test/resources/junit-platform.propertiesto your project that looks similar to this:https://github.com/junit-team/junit5/blob/2f3440e0f221255a83b28c42cf77407bde92a8b4/documentation/src/test/resources/junit-platform.properties#L1-L3