Spring Boot 4 testing strategies and patterns. Use when writing unit tests, slice tests (@WebMvcTest, @DataJpaTest), integration tests, Testcontainers with @ServiceConnection, security testing (@WithMockUser, JWT), or Modulith event testing with Scenario API. Covers the critical @MockitoBean migration from @MockBean.
/plugin marketplace add joaquimscosta/arkhe-claude-plugins/plugin install spring-boot@arkhe-claude-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
EXAMPLES.mdTROUBLESHOOTING.mdreferences/modulith-testing.mdreferences/security-testing.mdreferences/slice-tests.mdreferences/testcontainers.mdComprehensive testing patterns including slice tests, Testcontainers, security testing, and Modulith Scenario API.
| Old (Boot 3.x) | New (Boot 4.x) | Notes |
|---|---|---|
@MockBean | @MockitoBean | Required migration |
@SpyBean | @MockitoSpyBean | Required migration |
Implicit @AutoConfigureMockMvc | Explicit annotation required | Add to @SpringBootTest |
| Test Type | Annotation | Use When |
|---|---|---|
| Controller | @WebMvcTest | Testing request/response, validation |
| Repository | @DataJpaTest | Testing queries, entity mapping |
| JSON | @JsonTest | Testing serialization/deserialization |
| REST Client | @RestClientTest | Testing external API clients |
| Full Integration | @SpringBootTest | End-to-end, with real dependencies |
| Module | @ApplicationModuleTest | Testing bounded context in isolation |
@MockitoBean for external services@ServiceConnection for databases@WithMockUser, JWT mockingSee EXAMPLES.md for complete working examples including:
MockMvcTester and @MockitoBean (Java + Kotlin)TestEntityManager for lazy loading verification@ServiceConnection for PostgreSQL/Redis@WithMockUser for role-based accessScenario API| Anti-Pattern | Fix |
|---|---|
Using @MockBean in Boot 4 | Replace with @MockitoBean |
@SpringBootTest for unit tests | Use appropriate slice annotation |
Missing entityManager.clear() | Add to verify lazy loading |
| High-cardinality test data | Use minimal, focused fixtures |
| Shared mutable test state | Use @DirtiesContext or fresh containers |
| No security tests | Add @WithMockUser tests for endpoints |
@MockBean removed in Boot 4@DynamicPropertySourceCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.