/java-development:java-junitfrom java-development
Applies JUnit 5 best practices for Java tests including Maven/Gradle setup, parameterized tests, lifecycle hooks, assertions, Mockito isolation, tags, and nested tests.
Ships in java-development. 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.
None: SKILL.md is the whole skill.
Guide Java test implementation by turning behavior requirements into focused JUnit 5 tests that use idiomatic project structure, per-test lifecycle hooks, data-driven parameterized data, assertions, mocking, human-readable organization, and build-tool validation.
@ParameterizedTest."| Concern | Rule |
|---|---|
| Structure | Use standard Maven or Gradle layout; put tests in src/test/java. |
| Dependencies | Include junit-jupiter-api, junit-jupiter-engine, and junit-jupiter-params for parameterized tests. |
| Commands | Run mvn test or gradle test; narrow with build-tool filters when needed. |
| Class names | Use a Test suffix, for example CalculatorTest for Calculator. |
| Feature | Use | Notes |
|---|---|---|
@Test | Standard test methods. | One behavior per test. |
| Arrange-Act-Assert | Test body shape. | Keep setup, action, and verification clear. |
methodName_should_expectedBehavior_when_scenario | Descriptive naming. | Match existing project style if stronger. |
@BeforeEach / @AfterEach | Per-test setup and teardown. | Reset mutable state. |
@BeforeAll / @AfterAll | Per-class setup and teardown. | Static by default unless using a per-class lifecycle. |
@DisplayName | Human-readable class or method names. | Useful for business-readable scenarios. |
@Nested | Group related scenarios. | Keeps context-specific setup close to tests. |
| Source | Use it for | Notes |
|---|---|---|
@ParameterizedTest | Any test run with multiple input rows. | Pair with exactly one source. |
@ValueSource | Simple literal strings, ints, longs, doubles, classes, or booleans. | Best for one-parameter tests. |
@MethodSource | Factory method returning Stream, Collection, iterable, or arguments. | Best for computed or named cases. |
@CsvSource | Small inline comma-separated rows. | Keep rows readable. |
@CsvFileSource | CSV file from the classpath. | Use for larger stable datasets. |
@EnumSource | Enum constants. | Filter modes are useful for subsets. |
| Need | Assertion |
|---|---|
| Equality | assertEquals(expected, actual); baseline form assertEquals. |
| Truthiness | assertTrue, assertFalse. |
| Nullability | assertNotNull, assertNull. |
| Exception path | assertThrows. |
| No exception path | assertDoesNotThrow. |
| Multiple related checks | assertAll so all assertions run before failure. |
| Fluent style | AssertJ assertThat(...).is... only if the project already uses or accepts AssertJ. |
Import static methods from org.junit.jupiter.api.Assertions. Add descriptive messages when they make failure diagnostics clearer.
| Technique | Use when | Avoid |
|---|---|---|
| Mockito | Collaborators need isolation. | Mocking value objects or the class under test. |
@Mock | Declare mock dependencies. | Manual mock setup repeated across tests. |
@InjectMocks | Construct class under test from mocks. | Hiding complex construction that should be explicit. |
| Interfaces | Facilitate mocking and substitutions. | Introducing interfaces solely for trivial classes. |
| Packages | Group tests by feature or component. | Dumping all tests into one utility package. |
@Tag("fast"), @Tag("integration") | Categorize suites; baseline shorthand @Tag. | Using tags to hide slow tests instead of fixing scope. |
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) and @Order | Only when order is strictly necessary. | Routine unit tests; independence is preferred. |
@Disabled | Temporary skip with a reason. | Permanent silent skips. |
@TestMethodOrder only for rare ordered workflows, not normal unit tests.@SpringBootTest for ordinary unit tests: prefer plain JUnit and Mockito unless a Spring context is required.@Disabled: include a reason and track follow-up work.## JUnit 5 test plan
**Target:** `<class or behavior>`
**Command:** `mvn test` or `gradle test`
| Test | Annotation | Data source | Behavior verified |
| --- | --- | --- | --- |
| `<methodName_should_expectedBehavior_when_scenario>` | `@Test` or `@ParameterizedTest` | `<none / ValueSource / MethodSource / CsvSource / CsvFileSource / EnumSource>` | `<single behavior>` |
### Notes
- Lifecycle: `<BeforeEach/AfterEach/BeforeAll/AfterAll or none>`
- Assertions: `<Assertions or AssertJ>`
- Isolation: `<Mockito mocks or real collaborators>`
src/test/java and run with mvn test or gradle test.junit-jupiter-api, junit-jupiter-engine, and junit-jupiter-params when parameterized tests are used.@Test or @ParameterizedTest appropriately and follow Arrange-Act-Assert.assertThrows or assertDoesNotThrow where relevant.@Nested are used only when they clarify the test suite.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin java-development4 skills in this plugin
/create-spring-boot-java-projectCreate a Spring Boot Java project skeleton from Spring Initializr with Maven, Java 21, common data dependencies, SpringDoc, ArchUnit, local Docker Compose services for Redis, PostgreSQL, and MongoDB, application.properties settings, .gitignore entries, and Maven validation. Use when asked to create or scaffold a Spring Boot Java project./java-docsWrite and review Java Javadoc comments for public, protected, generic, deprecated, and complex members. Use this skill when the user asks for Java documentation, Javadoc best practices, missing comments, API docs, or documentation cleanup in Java code./Other plugins' skills for the same job