/java-kotlin-development:spring-boot-testingfrom java-kotlin-development
Selects and writes Spring Boot 4 tests using JUnit 6, AssertJ, MockMvcTester, RestTestClient, Testcontainers, and focused test slices. Guides on test slice selection, migration from @MockBean, and coverage priorities.
Ships in java-kotlin-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.
Read when SKILL.md points to them.
Choose the narrowest Spring Boot testing technique that provides confidence, then write maintainable tests with JUnit 6, AssertJ-style assertions, modern Spring Boot 4 test APIs, and meaningful coverage.
| Scenario | Use | Reference |
|---|---|---|
| Controller and HTTP semantics | @WebMvcTest with MockMvcTester | references/webmvctest.md, references/mockmvc-tester.md |
| Repository and JPA queries | @DataJpaTest with Testcontainers and a real database | references/datajpatest.md, references/testcontainers-jdbc.md |
| REST client and external APIs | @RestClientTest with MockRestServiceServer | references/restclienttest.md |
| JSON serialization and deserialization | @JsonTest | references/test-slices-overview.md |
| Business service logic | Plain JUnit plus Mockito, no Spring context | project tests |
| Full application wiring | @SpringBootTest with minimal context config | references/test-slices-overview.md |
| Spring Boot 4 HTTP integration | RestTestClient | references/resttestclient.md |
Decision tree:
Testing a controller endpoint? -> @WebMvcTest with MockMvcTester
Testing repository queries? -> @DataJpaTest with Testcontainers (real DB)
Testing business logic in service? -> Plain JUnit + Mockito (no Spring context)
Testing external API client? -> @RestClientTest with MockRestServiceServer
Testing JSON mapping? -> @JsonTest
Need full integration test? -> @SpringBootTest with minimal context config
| Principle | Rule |
|---|---|
| Test Pyramid | Prefer Unit (fast) > Slice (focused) > Integration (complete). |
| Right Tool | Use the narrowest slice that proves the behavior. |
| AssertJ Style | Prefer fluent, readable assertions over verbose matchers. |
| Modern APIs | Prefer MockMvcTester and RestTestClient over legacy alternatives when available. |
| Coverage Order | Test main scenario, other valid paths, then exceptions/errors. |
| Refactor signal | If one method needs more than 5-7 test cases, recommend extracting smaller focused functions before adding brittle tests. |
RestTestClient: modern alternative to TestRestTemplate.@MockitoBean: replaces deprecated @MockBean.MockMvcTester: AssertJ-style web test assertions.spring-boot-starter-webmvc-test.@DisplayName to state behavior: @DisplayName("Should calculate discount for VIP customer").80+% coverage as a practical minimum, but prioritize meaningful assertions over numeric coverage.Example display names:
@Test
@DisplayName("Should calculate discount for VIP customer")
void shouldCalculateDiscountForVip() { }
@Test
@DisplayName("Should reject order when customer has insufficient credit")
void shouldRejectOrderForInsufficientCredit() { }
Use only what the project needs:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
references/test-slices-overview.md: slice decision matrix and comparisons.references/webmvctest.md: web layer testing with MockMvc.references/datajpatest.md: data layer tests with Testcontainers.references/restclienttest.md: REST client testing.references/mockmvc-tester.md: AssertJ-style MockMvc usage.references/mockmvc-classic.md: traditional MockMvc for older projects.references/resttestclient.md: Spring Boot 4 REST client testing.references/mockitobean.md: dependency mocking with @MockitoBean.references/assertj-basics.md: scalar, string, boolean, and date assertions.references/assertj-collections.md: list, set, map, and array assertions.references/testcontainers-jdbc.md: PostgreSQL, MySQL, and JDBC containers.references/instancio.md: generating complex test objects with 3+ properties.references/context-caching.md: speeding up test suites.references/sb4-migration.md: Spring Boot 4 migration notes.Preserve these legacy terms, API names, command placeholders, and literal phrases when applying or migrating this skill:
Exceptions/Errors**OrderRequest## Spring Boot testing result
**Status:** tests-added | guidance-only | blocked
**Test strategy:** <unit/slice/integration and why>
| Target | Test type | Files changed | Main scenarios | Validation |
| --- | --- | --- | --- | --- |
| <class or endpoint> | <@WebMvcTest/@DataJpaTest/plain JUnit/etc.> | <test file> | <happy path, edge, error> | <command and result> |
### Notes
- <coverage, dependency, migration, or refactoring recommendation>
@MockBean was not introduced for Spring Boot 4 code; use @MockitoBean where needed.references/assertj-basics.md (opens in a new tab)references/assertj-collections.md (opens in a new tab)references/context-caching.md (opens in a new tab)references/datajpatest.md (opens in a new tab)references/instancio.md (opens in a new tab)references/mockitobean.md (opens in a new tab)references/mockmvc-classic.md (opens in a new tab)references/mockmvc-tester.md (opens in a new tab)references/restclienttest.md (opens in a new tab)references/resttestclient.md (opens in a new tab)references/sb4-migration.md (opens in a new tab)references/test-slices-overview.md (opens in a new tab)references/testcontainers-jdbc.md (opens in a new tab)references/webmvctest.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
8 skills in this plugin
/create-spring-boot-kotlin-projectCreate a Spring Boot Kotlin project skeleton from Spring Initializr with Gradle Kotlin DSL, Java 21, WebFlux, reactive data dependencies, SpringDoc, ArchUnit, and local Redis/PostgreSQL/MongoDB Docker services. Use when asked to create or scaffold a Spring Boot Kotlin project./java-add-graalvm-native-image-supportGraalVM Native Image expert that adds native image support to Java applications, builds the project, analyzes build errors, applies fixes, and iterates until successful compilation using Oracle best practices. Use this skill when the user asks for graalvm native image agent./java-helidonApply Helidon 4 SE and MP best practices for Java 21 applications, including routing, DB Client, Jakarta and MicroProfile APIs, configuration, security, observability, and tests. Use when working with Helidon SE, Helidon MP, HttpService, HttpRules, MicroProfile Config, Helidon DB Client, Helidon Security, or Helidon testing./java-refactoring-extract-methodRefactor Java 17 methods with the Extract Method technique to improve readability, testability, maintainability, reusability, modularity, cohesion, low coupling, and consistency. Use when the user asks to identify long or complex Java methods, extract helper methods, preserve behavior, and return complete compilable refactored code./java-refactoring-remove-parameterRefactor Java 17 methods by applying Remove Parameter safely. Use this skill when asked to remove unused or redundant Java method parameters, update call sites, preserve behavior, and return complete compilable refactored methods./javax-to-jakarta-migrationMigrate Java applications from `javax.*` APIs to `jakarta.*` APIs for Tomcat 11, Jakarta EE 10+, and framework upgrades. Use this skill when `javax` imports are detected, dependencies need Jakarta coordinates, `web.xml` namespaces must change, or compile errors follow a Jakarta migration.npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin java-kotlin-developmentOther plugins' skills for the same job