← ClaudeAtlas

tests-junitlisted

JVM backend test conventions — JUnit 5 in src/test/java, Surefire vs Failsafe, Maven and Gradle targeted reruns. Load when the resolved backend stack is java.
johantor/zion · ★ 1 · Code & Development · score 67
Install: claude install-skill johantor/zion
# Backend tests: JUnit (JVM) Detect the JUnit generation from the project's dependencies — the two are not source-compatible: - `junit-jupiter` / `org.junit.jupiter.api.Test` → **JUnit 5 (Jupiter)**. `@Test`, `@BeforeEach`/`@AfterEach`, `@Disabled`, `@ParameterizedTest`, `Assertions.assertX`. - `junit:junit:4.x` / `org.junit.Test` → **JUnit 4**. `@Before`/`@After`, `@Ignore`, `Assert.assertX`, `@RunWith`. - Both present (the vintage engine) → a migration in progress. Write new tests against Jupiter and leave the JUnit 4 ones alone unless asked. Check for `AssertJ` (`assertThat(x).isEqualTo(y)`) and `Mockito` before writing assertions or doubles — if the project uses them, follow it rather than dropping to bare `Assertions`. ## Layout Tests live in `src/test/java`, mirroring the production package path, with resources in `src/test/resources`. A test in the **same package** as its subject can reach package-private members without any reflection — prefer that to widening a production member's visibility for a test's sake. In a multi-module build each module has its own `src/test/java`; a test belongs to the module whose code it exercises, not to a central test module. ## Unit vs integration is a naming convention, and it is load-bearing Maven runs the two with different plugins, selected **by class name**: - **Surefire** runs unit tests: `*Test.java`, `Test*.java`, `*Tests.java`, `*TestCase.java` — during the `test` phase. - **Failsafe** runs integration tests: