JUnit 5 Tests Not Picked Up in CI - Add the Jupiter/Vintage Engine
JUnit 5 runs on the JUnit Platform with pluggable engines: junit-jupiter-engine runs JUnit 5 tests, junit-vintage-engine runs old JUnit 4 tests. If the engine for the style you wrote is absent, those tests are silently not discovered.
What this error means
A migrated suite shows fewer tests than expected, or Tests run: 0 for JUnit 5 classes. JUnit 4 tests vanish after dropping JUnit 4, because no vintage engine remains to run them.
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
# org.junit.jupiter.api.Test classes exist but no jupiter engine is on the classpathCommon causes
jupiter-engine missing
You depend on junit-jupiter-api (compiles annotations) but not junit-jupiter-engine (runs them), so the platform has nothing to execute JUnit 5 tests with.
Old JUnit 4 tests with no vintage engine
After moving to the platform, JUnit 4 @Test classes need junit-vintage-engine to run. Without it they are quietly skipped.
How to fix it
Add the Jupiter aggregator (and vintage if needed)
Use junit-jupiter (which pulls api + engine + params) and add vintage only for legacy tests.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<!-- only if you still have JUnit 4 tests -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>Enable the platform in Gradle
Gradle needs useJUnitPlatform() to run JUnit 5 at all.
test {
useJUnitPlatform()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.2'
}How to prevent it
- Depend on the
junit-jupiteraggregator, calluseJUnitPlatform()in Gradle, keep vintage only while JUnit 4 tests exist, and assert the expected test count in CI.