Skip to content
Latchkey

JUnit "No tests found / No runnable methods" in CI - Fix Test Discovery

When the build reports "No tests found" or "No runnable methods", the test runner discovered zero tests to run. Either the class/method naming does not match the discovery pattern, or the annotations belong to a JUnit version whose engine is not on the classpath.

What this error means

The build passes suspiciously fast with No tests found / Tests run: 0, or a class fails with No runnable methods (JUnit 4 finding no @Test). CI is green but nothing actually ran.

junit
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[WARNING] No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)

Common causes

Class/method names do not match the include pattern

Surefire by default includes *Test, Test*, *Tests. A class named MyTestCase or methods without @Test are silently skipped, yielding zero tests.

JUnit version/engine mismatch

JUnit 5 @Test (org.junit.jupiter) with only the JUnit 4 runner present (or vice versa) finds no runnable methods. No runnable methods is the classic JUnit 4 form.

How to fix it

Match naming or widen the include pattern

Rename classes to the convention, or configure Surefire to include yours, and fail the build if none run.

pom.xml
<configuration>
  <includes><include>**/*Test.java</include><include>**/*IT.java</include></includes>
  <failIfNoTests>true</failIfNoTests>
</configuration>

Align the JUnit engine with the annotations

  1. For JUnit 5, depend on junit-jupiter and a Surefire 3.x that auto-detects the platform.
  2. For mixed JUnit 4 + 5, add junit-vintage-engine so old tests still run.
  3. Set failIfNoTests=true so an empty discovery fails CI instead of passing green.

How to prevent it

  • Follow the *Test/*IT naming convention, set failIfNoTests=true, and keep the JUnit engine matched to the annotations you use.

Frequently asked questions

What causes ""No tests found / No runnable methods""?
Surefire by default includes *Test, Test*, *Tests. A class named MyTestCase or methods without @Test are silently skipped, yielding zero tests.
How do I fix "No tests found / No runnable methods"?
Rename classes to the convention, or configure Surefire to include yours, and fail the build if none run.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card