An inner class with JUnit 5 tests lacks @Nested, so its tests never run

tx0/java:nested-test-class-unmarkeddefaulterrorbug

What it finds

JUnit Jupiter discovers the tests of an inner, non-static class only when it is annotated @Nested; without it the class is ignored and its tests never run, while the build stays green.

Reported, in a file that imports org.junit.jupiter, is a non-static member class without @Nested that declares a method annotated @Test, @ParameterizedTest or @RepeatedTest.

From the rule's source, nested_test_class_unmarked.rs.

Example from the rule's tests
import org.junit.jupiter.api.Nested;import org.junit.jupiter.api.Test; class OuterTest {  class WhenEmpty {tx0 reports: never run without @Nested    @Test    void isEmpty() {}  }   @Nested  class WhenFull {    @Test    void isFull() {}  }   static class Helper {    @Test    void helps() {}  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/java:nested-test-class-unmarked" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:nested-test-class-unmarked] reason="..."

tx0 explain tx0/java:nested-test-class-unmarked shows the same in the terminal. Found a false positive? Report it.