spring-boot-testing

Test and migrate Spring Boot 3 code to Spring Boot 4 with standardized workflows.

21|4|Updated Oct 24, 2025
One-click install
npx skills add https://github.com/joaquimscosta/arkhe-claude-plugins --skill spring-boot-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spring-boot-testing
Source: https://github.com/joaquimscosta/arkhe-claude-plugins/tree/main/spring-boot/skills/spring-boot-testing
Command: npx skills add https://github.com/joaquimscosta/arkhe-claude-plugins --skill spring-boot-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides Boot 4 testing strategies and patterns, including the migration from @MockBean to @MockitoBean, slice tests, Testcontainers, security testing, and Modulith Scenario API.

Core Features & Use Cases

  • Slice Tests: @WebMvcTest with MockMvcTester and @MockitoBean
  • Testcontainers: @ServiceConnection for automatic container wiring
  • Security Testing: @WithMockUser and JWT testing
  • Modulith Testing: Scenario API-based verification

Quick Start

Create a @WebMvcTest with @MockitoBean, run tests, and verify results.

Frequently Asked Questions about spring-boot-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Spring Boot 3 tests to Boot 4 with @MockitoBean?

Spring Boot 4 replaces @MockBean with @MockitoBean and @SpyBean with @MockitoSpyBean. Update your test class annotations, then re-run your unit and slice tests. The Skill provides migration patterns for @WebMvcTest, @DataJpaTest, and security-testing scenarios with working examples and troubleshooting references.

What are slice tests and when should I use them in Spring Boot?

Slice tests target specific layers—@WebMvcTest for controllers, @DataJpaTest for repositories—loading only relevant beans and running faster than full integration tests. Use them to isolate and verify single components with mocked dependencies before running end-to-end tests.

How do I set up Testcontainers with Spring Boot 4 using @ServiceConnection?

@ServiceConnection automatically wires Docker containers into your Spring context without manual configuration. Declare a @ServiceConnection-annotated container field, and Boot 4 injects connection properties. This simplifies integration tests against real databases, message brokers, and services.

Can I test JWT security and @WithMockUser in Spring Boot 4 slice tests?

Yes. Spring Boot 4 slice tests support @WithMockUser for role-based testing and custom JWT scenarios in @WebMvcTest. The Skill covers both approaches, including MockMvcTester and WebTestClient assertion tools for verifying security filters and endpoint access control.

What's the difference between MockMvcTester and WebTestClient for testing Spring Boot endpoints?

MockMvcTester is the newer, fluent API for servlet-based @WebMvcTest slices with improved assertion syntax. WebTestClient handles reactive and async endpoints. Choose based on your application type—servlet stack or reactive stack—and Boot 4 slice test context.

How do I test Modulith modules in Spring Boot 4 using the Scenario API?

Modulith's Scenario API lets you verify module interactions and event flows without mocking. Boot 4 slice tests work with Scenario for isolated module verification. The Skill shows end-to-end workflows combining slice tests, @MockitoBean, and Scenario-based assertions.