[ https://issues.apache.org/jira/browse/SUREFIRE-2033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17509354#comment-17509354 ]
Robert James Oxspring commented on SUREFIRE-2033: ------------------------------------------------- The documentation is also very clear about the precedence algorithm used to choose the engine/runner to use: [https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html] If nothing is configured, Surefire detects which JUnit version to use by the following algorithm: # if the JUnit 5 Platform Engine is present in the project # use junit-platform # if the JUnit version in the project >= 4.7 and the <<<parallel>>> configuration parameter has ANY value # use junit47 provider # if JUnit >= 4.0 is present # use junit4 provider # else # use junit3.8.1 Prior to M5, surefire worked as documented and actively preferred to use JUnit 5 if the engine is present. Since M5, switches away from this documented behaviour and conditionally prefers to run the older junit-platform-runner, if present, effectively preferring JUnit 4. As discussed previously, we have a business requirement for our product to use junit-platform-runner, but tests of our product are using JUnit 5 and have been run via the junit-Jupiter-engine for as long as I can remember. You may find this a silly requirement, and I’d love to change it, but that is what the business requires. Your main concern seems to be that use of junit-platform-runner is unusual and not a recommended configuration. Given this, doesn’t it seem odd that M5 changes behaviour to actively prefer this unusual unrecommended runner over the Junit Jupiter Engine that is also present? > Regression: 3.0.0-M5 misidentifies JUnit 5 configuration as JUnit 4 > ------------------------------------------------------------------- > > Key: SUREFIRE-2033 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2033 > Project: Maven Surefire > Issue Type: Bug > Components: JUnit 5.x support > Affects Versions: 3.0.0-M5 > Reporter: Robert James Oxspring > Priority: Major > Attachments: example.zip > > > 3.0.0-M5 misidentifies a clearly JUnit 5 configuration and attempts to run > using JUnit 4. > In particular the attached project only has JUnit 5 dependencies: > {code:java} > <dependencies> > <dependency> > <groupId>org.junit.jupiter</groupId> > <artifactId>junit-jupiter-engine</artifactId> > <version>5.6.2</version> > <scope>test</scope> > </dependency> > <dependency> > <groupId>org.junit.platform</groupId> > <artifactId>junit-platform-runner</artifactId> > <version>1.6.2</version> > <scope>test</scope> > </dependency> > </dependencies>{code} > and a JUnit 5 test: > {code:java} > package pkg; > import org.junit.jupiter.api.Test; > class JUnit5Test { > @Test > public void test() { > } > }{code} > When the project is run with with older version (as far back as 2.22.0) the > test is found and run, but 3.0.0-M5 fails to run any test: > {code:java} > % mvn test -Dsurefire.version=2.22.0 | tail > [INFO] Results: > [INFO] > [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 > [INFO] > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1.337 s > [INFO] Finished at: 2022-03-03T09:42:27Z > [INFO] > ------------------------------------------------------------------------ > {code} > > {code:java} > % mvn test -Dsurefire.version=3.0.0-M1 | tail > [INFO] Results: > [INFO] > [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 > [INFO] > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1.708 s > [INFO] Finished at: 2022-03-03T09:34:58Z > [INFO] > ------------------------------------------------------------------------ > % mvn test -Dsurefire.version=3.0.0-M2 | tail > [INFO] Results: > [INFO] > [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 > [INFO] > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1.701 s > [INFO] Finished at: 2022-03-03T09:36:26Z > [INFO] > ------------------------------------------------------------------------ > % mvn test -Dsurefire.version=3.0.0-M3 | tail > [INFO] Results: > [INFO] > [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 > [INFO] > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1.612 s > [INFO] Finished at: 2022-03-03T09:37:02Z > [INFO] > ------------------------------------------------------------------------ > % mvn test -Dsurefire.version=3.0.0-M4 | tail > [INFO] Results: > [INFO] > [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 > [INFO] > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1.619 s > [INFO] Finished at: 2022-03-03T09:37:37Z > [INFO] > ------------------------------------------------------------------------ > % mvn test -Dsurefire.version=3.0.0-M5 | tail > [INFO] Results: > [INFO] > [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 > [INFO] > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1.344 s > [INFO] Finished at: 2022-03-03T09:38:01Z > [INFO] > ------------------------------------------------------------------------{code} > Note the final run above using 3.0.0-M5 and logging: {{Tests run: 0}} -- This message was sent by Atlassian Jira (v8.20.1#820001)