What this thread does
Do first: run mvn test -DfailIfNoTests=true in the module that owns the tests, then select one compiled test with -Dtest=MyTest if discovery is empty.
Short answer
As of November 2026, Surefire 3.6.1 scans by class-name patterns and executes tests through JUnit Platform. Jupiter tests need an engine as well as their annotation API. The current JUnit 6.1.3 guide requires Java 17 or later at runtime; keep the project's supported JUnit line when its runtime is older.
Choose / don't choose
- Nonstandard class name: choose an explicit include pattern or adopt a default pattern; don't rename an existing
*Testsclass solely because an old answer says it is excluded. The documented**/*Tests.javapattern includes it (patterns). - Jupiter annotation: choose the
junit-jupiter-enginedependency fororg.junit.jupiter.api.Test; don't expect a legacy JUnit provider or annotation API alone to execute it (engine setup). - Zero tests allowed in helper modules: scope the fail-on-empty policy to modules expected to contain tests; don't weaken it globally to hide a discovery problem (failure controls).
Not for: intentionally skipping test execution during packaging or Failsafe integration-test discovery.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
includes | Without overrides: **/Test*.java, **/*Test.java, **/*Tests.java, **/*TestCase.java | Surefire 3.6.1 | default patterns |
<includes><include>Sample.java</include></includes> | Explicit documented selection for a nonstandard class; adapt to your intended class/path; keep the defaults too if they should still be selected | Surefire 3.6.1 | override example |
failIfNoTests | Set true where tests are expected; default false | Surefire 3.6.1 | goal reference |
test | MyTest selects one test class; adapt the class name | Surefire 3.6.1 | single class |
surefire.failIfNoSpecifiedTests | Retain default true for an explicit selector that should match | Surefire 3.6.1 | selector failure |
org.junit.jupiter:junit-jupiter | Test-scoped dependency; 6.1.3 as documented, or version managed by its aligned BOM | JUnit 6.1.3; Surefire/Failsafe minimum 3.0.0 | Maven dependencies |
Order of operations
1. Confirm this is the owning module and test execution has not been skipped. Confirm test sources compile into the configured testClassesDirectory; its default is ${project.build.testOutputDirectory}, not a manually selected source directory (goal reference). 2. Run mvn -Dtest=TestCircle test, replacing TestCircle with an actual compiled test class. This isolates the selector from the default broad scan; keep the selector-empty failure enabled (selector). 3. If the class is found but has no runnable Jupiter cases, inspect its annotation import and the runtime engine. Use test-scoped junit-jupiter-engine, which pulls in junit-jupiter-api, or the dependency above. Since Surefire 3.6.0, JUnit Platform is the unified execution mechanism; don't copy the older provider-selection algorithm (current provider, JUnit dependencies). 4. Inspect custom includes, excludes, tag/engine filters and nested-class layout. Nested classes, including static member classes, are excluded by default; a top-level scan is different from an engine's nested-test semantics (filters). Restore the intended suite-wide naming rules after the single-class run and require a nonzero expected case count.
Known failures and fixes
| Error or symptom | Cause | Fix | Source |
|---|---|---|---|
There are no tests to run. | Reported Maven program compiled but mvn test did not run tests; Surefire configuration can specify tests to include or exclude | Inspect current include/exclude rules and select a known compiled class before changing dependencies | report, current patterns |
| Jupiter test compiles but is not executed (symptom) | A TestEngine implementation must be on the classpath | Supply aligned Jupiter engine/API dependencies and inspect filters | JUnit runtime requirement, Surefire engine setup |
Missing
- No POM, annotation import or compiled-class inventory is specified. A particular missing engine or selector cannot be diagnosed from an empty count alone.
Checked
2026-11-12; Surefire 3.6.1 goal/pattern/selector/provider docs, JUnit 6.1.3 overview/build support and the dated discovery report read. No Maven commands executed.
Started from a post by @Apache Maven, packaged by the editor. Original post