agentsclimarketplace

Spring boot testing

Skill joaquimscosta/arkhe-claude-plugins/plugins/spring-boot/skills/spring-boot-testing

Supercharge Claude Code with 109 specialized components — 22 agents, 32 commands, 55 skills across 13 modular plugins. Deep reasoning, autonomous dev loops, DDD architecture, design system enforcement, git automation, and more.

Install
npx -y skills add joaquimscosta/arkhe-claude-plugins --skill spring-boot-testing

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 21 stars21 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

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.

SKILL.md

4.6 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

Spring Boot 4 Testing

Comprehensive testing patterns including slice tests, Testcontainers, security testing, and Modulith Scenario API.

Critical Breaking Change

Old (Boot 3.x)New (Boot 4.x)Notes
@MockBean@MockitoBeanRequired migration
@SpyBean@MockitoSpyBeanRequired migration
MockMvc (procedural)MockMvcTester (fluent)New AssertJ-style API
Implicit @AutoConfigureMockMvcExplicit annotation requiredAdd to @SpringBootTest

MockMvcTester (Spring Boot 4)

New fluent, AssertJ-style API for controller testing:

@WebMvcTest(UserController.class)
class UserControllerTest {

    @Autowired
    private MockMvcTester mvc;  // NEW: Fluent API

    @Test
    void getUser_returnsUser() {
        mvc.get().uri("/users/{id}", 1)
            .exchange()
            .assertThat()
            .hasStatusOk()
            .bodyJson()
            .extractingPath("$.name")
            .isEqualTo("John");
    }
}

Key Benefits: Fluent assertions, better error messages, AssertJ integration.

Test Annotation Selection

Test TypeAnnotationUse When
Controller@WebMvcTestTesting request/response, validation
Repository@DataJpaTestTesting queries, entity mapping
JSON@JsonTestTesting serialization/deserialization
REST Client@RestClientTestTesting external API clients
Full Integration@SpringBootTestEnd-to-end, with real dependencies
Module@ApplicationModuleTestTesting bounded context in isolation

Core Workflow

  1. Choose test slice → Minimal context for fast tests
  2. Mock dependencies@MockitoBean for external services
  3. Use Testcontainers@ServiceConnection for databases
  4. Assert thoroughly → Use AssertJ, MockMvcTester (new), RestTestClient (new), WebTestClient
  5. Test security@WithMockUser, JWT mocking

Quick Patterns

See EXAMPLES.md for complete working examples including:

  • @WebMvcTest with MockMvcTester and @MockitoBean (Java + Kotlin)
  • @DataJpaTest with TestEntityManager for lazy loading verification
  • Testcontainers with @ServiceConnection for PostgreSQL/Redis
  • Security Testing with @WithMockUser for role-based access
  • Modulith Event Testing with Scenario API

Detailed References

Anti-Pattern Checklist

Anti-PatternFix
Using @MockBean in Boot 4Replace with @MockitoBean
@SpringBootTest for unit testsUse appropriate slice annotation
Missing entityManager.clear()Add to verify lazy loading
High-cardinality test dataUse minimal, focused fixtures
Shared mutable test stateUse @DirtiesContext or fresh containers
No security testsAdd @WithMockUser tests for endpoints

Related Skills

NeedSkill
Security configurationspring-boot-security
Module boundariesspring-boot-modulith
Data layer patternsspring-boot-data-ddd
Controller patternsspring-boot-web-api

Critical Reminders

  1. @MockitoBean is mandatory@MockBean removed in Boot 4
  2. Slice tests are fast — Use them for focused testing
  3. Clear EntityManager — Required to test lazy loading behavior
  4. @ServiceConnection simplifies Testcontainers — No more @DynamicPropertySource
  5. Test security explicitly — Don't rely on disabled security

What ships with it: 6 files

57.8 KB alongside SKILL.md

Keep looking

Skills are one crate of 327,069. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.