PlugWiki

java-junit Skill for Claude Code: Write and Fix Java Tests With JUnit

Teaches Claude to write and fix Java unit tests with JUnit 5 or 6, AssertJ and Mockito, and never to skip or delete a failing test to get green.

Installs
11.8K
on skills.sh
Stars
40.7K
on GitHub
Files
2
besides SKILL.md
Updated
Oct 2026
last repo commit

java-junit makes Claude check your build first (pom.xml or build.gradle), copy the conventions already in src/test/java, and not add AssertJ, Mockito or JaCoCo to a project that lacks them without asking. It then gives rules for assertions, mocking, deterministic time and randomness, and the split between unit tests (Surefire) and integration tests (Failsafe). Coverage and PIT mutation testing are optional.

Its agent guardrails are the key part: never delete, disable or weaken a failing test, ask before changing production behavior, and never add flags like -DskipTests. Claude runs the narrowest test first, then the full build, so it will run Maven or Gradle in your project. The folder holds 3 Markdown files and no scripts.

Good for

  • Java developers who want Claude to fix failing tests, not hide them
  • Teams that want new tests to match their existing style
  • Maven and Gradle users on JUnit 5 or 6

Install java-junit

Claude Code

  1. 1

    Download the skill folder from https://github.com/github/awesome-copilot/tree/HEAD/skills/java-junit.

  2. 2

    Put it at ~/.claude/skills/java-junit/ so that SKILL.md sits directly inside.

  3. 3

    Start a new session; the skill loads when its description matches the task.

Built from the package data we hold. Not yet tested by us.

What's in the skill

When it loads

Write, review and fix Java unit tests with JUnit 5 and JUnit 6 (Jupiter), AssertJ and Mockito: assertions, parameterized and nested tests, mocking rules, deterministic time and randomness, Surefire vs Failsafe, JaCoCo coverage, optional PIT mutation testing, and guardrails for agents (never skip or delete failing tests). Use when adding, refactoring or debugging tests in Maven or Gradle projects. Framework-neutral.

Sections in SKILL.md

  1. First: detect, don't impose
  2. JUnit 5 vs JUnit 6
  3. Assertions
  4. Mocking (Mockito)
  5. Determinism
  6. Unit vs integration tests
  7. Coverage and mutation testing (optional)
  8. Agent guardrails
  9. References

Key facts

License
MIT
Installs on skills.sh
11,757 (Nov 2, 2026)
Files in the skill folder
3 files including SKILL.md

What it includes

  • Reads the build files and copies existing test conventions.

    Won't add AssertJ, Mockito or JaCoCo to a project without them unless you agree.

    Read · Detect, don't impose

  • A comparison table for Java baseline, versioning and removed APIs.

    Says to prefer the release notes for your target version over its table.

    JUnit 5 vs JUnit 6

  • Expected value first, lazy messages, assertAll, no bare assertNotNull.

    Match the project's library.

    Assertion rules

  • Mock collaborators across a boundary, not value objects or the class under test.

    Prefers hand-written fakes for stateful interactions.

    Mocking rules

  • Inject a Clock and a seeded Random.

    Avoids default locale, time zone, network and sleeps.

    Determinism

  • Surefire for *Test, Failsafe for *IT.

    Maven and Gradle setups for each.

    Runs code · Unit vs integration tests

  • Optional JaCoCo and PIT.

    Only if the project uses them or you ask. PIT run is slow.

    Runs code · Coverage and mutation testing

  • Seven rules, such as never skip a failing test and run the narrowest test first.

    Rule 3 bars -DskipTests and similar flags.

    Runs code · Agent guardrails

  • mvn -Dtest=..., mvn verify, ./gradlew test --tests, ./gradlew check.

    Prefers the project wrapper (mvnw or gradlew) when present.

    Runs code · Run commands

  • AssertJ and Mockito patterns, and Maven and Gradle build setups.

    Two files in references/.

    References

From the official docs

Permissions

Low risk

Claude will run Maven or Gradle in your project, which downloads dependencies and executes your code and tests. Check the diff for any test it changed.

What it can do

  • Read your data
  • Create and change things
  • Delete things
  • Read-only mode

Watch out for

  • It runs your build tool

    The SKILL.md has Claude run mvn test, mvn verify, ./gradlew test and ./gradlew check, which pull dependencies and run project code. Use a clean checkout if the project is untrusted. github.com

  • It edits test files and build files

    The reference shows pom.xml and Gradle changes for JaCoCo and PIT. The SKILL.md says to add them only if the project uses them or you ask. github.com

  • Guardrail against hiding failures

    The SKILL.md bars deleting, disabling or weakening failing tests and adding skip flags. Still read the diff. github.com

Technical details
Scopes
  • Runs mvn, mvnw, gradle or gradlew in the project

Questions

What does java-junit do?

It teaches Claude how to write, review and fix Java unit tests with JUnit 5 or 6, AssertJ and Mockito. It also sets guardrails so Claude does not make a build green by skipping or weakening tests.

How do I install it?

Use the install box above. In Copilot CLI you can install the java-development plugin, which holds this skill and three others. For Claude Code the box shows the skill folder routes.

Does it work in Claude.ai, Codex or Cursor?

The README documents Copilot plugins. The skill is plain Markdown, and the box shows generated folder installs for Claude Code, the Claude app and Codex. The authors do not state tests in those clients.

Does it support JUnit 6?

Yes. The SKILL.md has a JUnit 5 vs 6 table and says the Jupiter tests in the skill compile and pass on 5.14.4 and 6.0.3. It says never to bump the major version implicitly.

Is it safe?

The skill bundles no scripts, but it makes Claude run Maven or Gradle builds in your project, which download dependencies and run your code. It also edits test files. Review diffs and keep the guardrail against skipped tests in mind.

Will it change my production code?

The SKILL.md says that if a fix changes production behavior, Claude must stop and ask first.

java-junit vs spring-boot-testing?

java-junit is framework-neutral. For Spring test slices the SKILL.md points to spring-boot-testing, for Docker-based tests to java-testcontainers, and for unexplained failures to java-debugging, each if installed.

Information

updated Nov 2, 2026

Folder
skills/java-junit

github/awesome-copilotskills.sh

Sources

Docs, issue trackers and discussions this page is built from.

Show all 6
  1. awesome-copilot README · github.com
  2. java-development plugin README · github.com
  3. java-junit SKILL.md · github.com
  4. build-setup.md · github.com
  5. assertj-and-mockito.md · github.com
  6. java-development plugin.json · github.com

Updated Nov 2, 2026.