mercredi 10 juin 2020

JUnit5 parallel test execution causes first other test to not execute in maven build

I have a project using JUnit5 which contains around 100 test classes and a total of >1000 tests. All of them run sequentially.

Now I created a new test that needs to run the test methods inside in parallel.

I added a junit-platform.properties file and added the following parameter: junit.jupiter.execution.parallel.enabled = true

Then I annotated the new test class with @Execution(ExecutionMode.CONCURRENT) and it is working just fine if I run the tests in IntelliJ. All tests in the other test classes also keep running sequentially in the same thread as I didn't specify the parameters junit.jupiter.execution.parallel.mode.default and junit.jupiter.execution.parallel.mode.classes.default so they default to same_thread.

So far, so good. But when I perform a mvn clean install I get one of two possible outcomes:

  1. The parallel tests in the new test class don't run

or

  1. The parallel tests in the new test class run but the tests in the very first test class of the other test classes don't run. All other test classes after that first one keep running.

It also seems completely random which case occurs. running maven clean install 10 times ends up at like 50-50.

The new test class contains 5 tests while the very first test class of the other tests contains 15 tests. So in case 1 1205/1220 tests get run and in case 2 1215/1220

I tried adding another experimental test class which gets executed before the original first test class to make sure this always concerns the first executed test class by maven. This was the case. The original "first" test class runs every time while the new experimental test class gets run or not, depending on outcome 1 or 2 from above.

Does anyone know what could be the issue here?

Aucun commentaire:

Enregistrer un commentaire