Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit 5 with Maven Surefire does not run parallel tests #1424

Closed
jennyowen opened this issue May 18, 2018 · 6 comments
Closed

JUnit 5 with Maven Surefire does not run parallel tests #1424

jennyowen opened this issue May 18, 2018 · 6 comments

Comments

@jennyowen
Copy link

overview

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.

reproduction code

I included reproduction code in this gist: https://gist.github.com/jennyowen/563dbf93315e357bdf9e0bb2e098600b

versions

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

related issues

#809 #1341

@marcphilipp
Copy link
Member

<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 #801 (comment)). Please note that we're currently handing over the provider to the Surefire project: apache/maven-surefire#184.

@sbrannen sbrannen changed the title JUnit5 with surefire does not run parallelised tests JUnit 5 with Maven Surefire does not run parallel tests May 22, 2018
@sormuras
Copy link
Member

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.

@dm9tr0
Copy link

dm9tr0 commented Jul 13, 2018

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

@marcphilipp
Copy link
Member

@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:

junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.config.fixed.parallelism=6

@BalurQA
Copy link

BalurQA commented May 11, 2020

@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.

@marcphilipp
Copy link
Member

@BalurQA I'm not sure. Are you running your tests in a different way on Jenkins? Is the file still around in its workspace?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants