Mix of junit4 and junit5 on classpath confuses Eclipse
iloveeclipse opened this issue · comments
@trancexpress tried to run latest JUnit tests (for #2326) inside Eclipse 4.27, got zero tests found/executed.
The reason seem to be a mix of JUnit4 / JUnit5 runtimes generated in .classpath files (but might be something related to Eclipse itself, see eclipse-pde/eclipse.pde#390) and that new Eclipse uses JUnit 5 by default.
Anyway, I see the mix is coming from different JUnit versions referenced by gradle build files:
git grep junit | grep gradle
build.gradle: def junitVersion = '5.9.2'
build.gradle: compileOnly platform("org.junit:junit-bom:$junitVersion")
build.gradle: testImplementation platform("org.junit:junit-bom:$junitVersion")
build.gradle: !it.toString().contains("-test") && !it.toString().contains("Test") && !it.toString().contains("junit")
eclipsePlugin-junit/build.gradle: testImplementation 'junit:junit:4.13.2'
settings.gradle.kts:include(":eclipsePlugin-junit")
spotbugs-ant/build.gradle: testImplementation 'junit:junit:4.13.2'
spotbugs-tests/build.gradle: implementation 'junit:junit:4.13.2'
spotbugsTestCases/build.gradle: implementation 'junit:junit:4.13.2'
test-harness-jupiter/build.gradle: compileOnly 'org.junit.jupiter:junit-jupiter-api'
test-harness-jupiter/build.gradle: testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
test-harness-jupiter/build.gradle: testImplementation 'org.junit.jupiter:junit-jupiter-api'
test-harness/build.gradle: compileOnly 'junit:junit:4.13.2'
Ideally we should use one JUnit version in the project.
In the maven world, this simply means not using surefire version 3 that supported the mix. Further the vintage engine must be used since its the entry point to legacy. I suspect the same would be true here. There really is no reason we rely on junit 4 directly anyways since 2017. Noticed that a while back but haven't done anything yet to address as gradle for a while didn't runt this project at all well in windows, I'm told its fixed now so I'll have a look at the libraries in general soon.
fixing per #2483