Minimal reproducer for a Maven Surefire 3.6.0 regression: a Spock specification aborts
JUnit Platform discovery — taking the whole fork with it — when <excludedGroups> is
configured and the JUnit 4 jar is on the test classpath.
src/test/groovy/com/example/ExampleSpec.groovy— one trivial Spock feature,def "addition works"()src/test/java/com/example/ExampleTest.java— one trivial JUnit Jupiter testpom.xml— Spock 2.4-groovy-4.0, Groovy 4.0.33, JUnit 5.14.1,junit:junit:4.13.2, and<excludedGroups>${excluded.groups}</excludedGroups>
Two properties control the reproduction:
| property | default |
|---|---|
surefire.version |
3.6.0 |
excluded.groups |
slow |
mvn test -Dsurefire.version=3.5.6 # Tests run: 2, BUILD SUCCESS
mvn test -Dsurefire.version=3.6.0 # Tests run: 0, BUILD FAILURE
The failure:
[ERROR] Could not find method with name [addition works] in class [com.example.ExampleSpec].
[ERROR] There was an error in the forked process
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
All three conditions are jointly necessary:
| surefire | excludedGroups |
junit:junit on classpath |
tests run |
|---|---|---|---|
| 3.5.6 | slow |
yes | 2 |
| 3.6.0 | (empty) | yes | 2 |
| 3.6.0 | slow |
no | 2 |
| 3.6.0 | slow |
yes | 0, BUILD FAILURE |
| 3.6.0-M1 | slow |
yes | 0, BUILD FAILURE |
Use -Dexcluded.groups= for row 2; remove the junit:junit dependency from pom.xml for row 3.
Note that the Jupiter test does not run either — discovery aborts for every engine, not just for the Spock spec that triggers it.