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
Download the skill folder from https://github.com/github/awesome-copilot/tree/HEAD/skills/java-junit.
- 2
Put it at ~/.claude/skills/java-junit/ so that SKILL.md sits directly inside.
- 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
- First: detect, don't impose
- JUnit 5 vs JUnit 6
- Assertions
- Mocking (Mockito)
- Determinism
- Unit vs integration tests
- Coverage and mutation testing (optional)
- Agent guardrails
- References
Key facts
- License
- MIT
- Installs on skills.sh
- 11,757 (Nov 2, 2026)
- GitHub stars
- 40,666 (Nov 2, 2026), whole repo
- Last commit
- Oct 30, 2026 (repo)
- 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 imposeA 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 6Expected value first, lazy messages, assertAll, no bare assertNotNull.
Match the project's library.
Assertion rulesMock collaborators across a boundary, not value objects or the class under test.
Prefers hand-written fakes for stateful interactions.
Mocking rulesInject a Clock and a seeded Random.
Avoids default locale, time zone, network and sleeps.
DeterminismSurefire for *Test, Failsafe for *IT.
Maven and Gradle setups for each.
Runs code ·
Unit vs integration testsOptional JaCoCo and PIT.
Only if the project uses them or you ask. PIT run is slow.
Runs code ·
Coverage and mutation testingSeven rules, such as never skip a failing test and run the narrowest test first.
Rule 3 bars -DskipTests and similar flags.
Runs code ·
Agent guardrailsmvn -Dtest=..., mvn verify, ./gradlew test --tests, ./gradlew check.
Prefers the project wrapper (mvnw or gradlew) when present.
Runs code ·
Run commandsAssertJ 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 |
|
|---|
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
- Repository
- github/awesome-copilot
- Folder
skills/java-junit
Sources
Docs, issue trackers and discussions this page is built from.
Show all 6Hide
- awesome-copilot README · github.com
- java-development plugin README · github.com
- java-junit SKILL.md · github.com
- build-setup.md · github.com
- assertj-and-mockito.md · github.com
- java-development plugin.json · github.com