java-junit
Installation
SKILL.md
Java Testing with JUnit 5/6, AssertJ and Mockito
Framework-neutral guidance for fast, deterministic unit tests. For Spring slices use spring-boot-testing (if installed); for real databases/brokers in Docker use java-testcontainers; for failures you cannot explain, java-debugging.
First: detect, don't impose
- Read
pom.xml/build.gradle*: JUnit version (junit-jupiter,junit-bom, or inherited from a Spring Boot BOM), assertion library, Mockito, Surefire/Failsafe versions, Java release. - Copy the conventions already in
src/test/java(naming, assertion library, static imports, mocking style). Do not introduce AssertJ, Mockito or JaCoCo into a project that lacks them without asking. - Never bump the JUnit major version implicitly; upgrading is its own task (see
java-upgradeif installed).
JUnit 5 vs JUnit 6
| JUnit 5 (last 5.14.x) | JUnit 6 (6.0 released; 6.1.x current) | |
|---|---|---|
| Java baseline | 8 | 17 (verified in the published Gradle module metadata) |
| Versioning | Platform 1.x, Jupiter 5.x, Vintage 5.x | One version number for Platform, Jupiter and Vintage |
| API | org.junit.jupiter.api.* |
Same packages; the Jupiter tests in this skill compile and pass unchanged on 5.14.4 and 6.0.3 |
| Removed in 6.0 | MethodOrderer.Alphanumeric, the deprecated two-argument InvocationInterceptor.interceptDynamicTest(Invocation, ExtensionContext) overload (the three-argument one remains), junit.jupiter.tempdir.scope, @CsvFileSource(lineSeparator) |
|
| CSV | univocity-parsers | FastCSV: stricter parsing (no characters after a closing quote); header-field options now apply to headers |
| Other | junit-jupiter-migrationsupport deprecated; invalid enum-style config values now fail discovery; @Nested class order deterministic but non-obvious |