/java-testing:java-testingfrom java-testing
Writes, runs, debugs and fixes Java tests with JUnit Jupiter 5/6, Mockito, AssertJ and Testcontainers. Use when editing or debugging JUnit code (*Test.java, *IT.java): @ParameterizedTest, @Nested, Mockito UnnecessaryStubbingException or strict stubs, "No tests found for given includes", -Dtest or --tests filtering, Surefire versus Failsafe, flaky tests that sleep or depend on the clock, a slow suite starting a container per class, Mockito agent warnings on Java 21+.
Ships in java-testing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Test behavior through the public API with the framework the project already uses. Read the build file first: JUnit 4 vs Jupiter, AssertJ vs Hamcrest, Mockito version, and the Java release.
Not for: general test strategy and what to test (unit-testing); anything that needs a Spring context, such as @WebMvcTest, @DataJpaTest, @SpringBootTest, @MockitoBean (spring-boot-testing); Kotlin tests (kotlin-testing); tests that need Android, such as Robolectric and instrumented tests (android-testing); build wiring (maven, gradle); production code design (java).
Verified on 2026-10-20: JUnit 6 requires Java 17 at runtime (code compiled for older releases can still be tested), and Platform, Jupiter and Vintage share one version (6.1.3); Vintage, the JUnit 3/4 engine, is deprecated. Mockito 5 uses the inline mock maker by default. On Java 21+ Mockito self-attaching prints a JVM warning and may fail later; configure -javaagent (see references/mockito.md).
org.junit.jupiter.api) and JUnit 4 (org.junit.Test) do not mix: a Jupiter @Test in a JUnit 4 setup is silently never run. Use the Jupiter imports in new tests unless the whole module is on JUnit 4.junit-jupiter-api, -params and -engine on one version (use the junit-bom). JUnit 6 versions the Platform, Jupiter and Vintage together.Assertions otherwise.<Subject>Test, one behavior per method, Arrange-Act-Assert. Name methods for behavior (rejectsExpiredToken), not for the method under test. Use @DisplayName only when the project does.@BeforeEach for per-test setup; @BeforeAll must be static unless the class is @TestInstance(PER_CLASS).@Nested to group cases by state or scenario, @Tag("integration") to select a lane in the build, and @Disabled("reason") with a reason and a ticket.assertThrows (or AssertJ assertThatThrownBy) and check the type and a stable part of the message or cause. Use assertAll or AssertJ SoftAssertions when one result has several properties; a test that asserts a dozen unrelated things is several tests.usingRecursiveComparison() rather than adding equals to production code for the test's sake.Collapse copy-pasted cases with @ParameterizedTest, not loops inside a test.
| Source | Use for |
|---|---|
@ValueSource, @NullAndEmptySource | one literal argument, plus null and empty |
@CsvSource, @CsvFileSource | input and expected-output rows |
@EnumSource | every (or a filtered) enum constant |
@MethodSource("name") | objects, Arguments.of(...), shared providers (static unless PER_CLASS) |
Set name = "{0} -> {1}" so a failing row is identifiable. Put boundary values in the rows: empty, null, zero, max, off-by-one.
@ExtendWith(MockitoExtension.class) with @Mock; its strict stubs fail a test on an unused stub (UnnecessaryStubbingException). Delete the stub or fix the code path; do not reach for lenient() unless a shared @BeforeEach stub is truly used by only some tests.verify only for side effects that are the behavior (an email sent, an event published). Don't verify every stubbed call.java.time.Clock (or Supplier<Instant>) instead of calling LocalDate.now() or Instant.now(); tests use Clock.fixed(...). Inject randomness and ID generators the same way.Thread.sleep to wait for async work. Wait on the thing itself: CompletableFuture.get(timeout), a CountDownLatch, or Awaitility (await().atMost(Duration.ofSeconds(5)).untilAsserted(...)). Pass an executor in so tests can run work synchronously.@TempDir for files and @Timeout on tests that could hang.*IT and run them with Failsafe (mvn verify), or in a separate Gradle test task, so mvn test stays fast.@Container is once per class; read references/testcontainers.md for reuse and wait strategies.@ServiceConnection from spring-boot-testing.Use JaCoCo to find untested branches in code you changed, not to hit a number. Don't add a percentage gate or write assertion-free tests to raise it. See references/coverage.md.
-pl <module> -am.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin java-testing