springboot-tdd

Guides test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, and Testcontainers.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill springboot-tdd-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: springboot-tdd
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/springboot-tdd
Command: npx skills add https://github.com/ibytechaos/claude --skill springboot-tdd-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Spring Boot tests requires choosing the right test slice, mocking strategy, and coverage tooling, and this Skill provides a structured TDD workflow with ready-to-use patterns for each layer. ## Core Features & Use Cases - Layered Test Patterns: Provides templates for unit tests (JUnit 5 + Mockito), web layer tests (MockMvc), persistence tests (@DataJpaTest), and full integration tests (@SpringBootTest). - Testcontainers & Coverage: Shows how to wire Testcontainers via @DynamicPropertySource and enforce 80%+ coverage with the JaCoCo Maven plugin. - Use Case: When adding a new REST endpoint to a Spring Boot service, follow the red-green-refactor workflow: write a failing MockMvc test, implement the controller, then add repository and integration tests before merging. ## Quick Start Ask the AI to apply the springboot-tdd workflow to write tests first for a new Spring Boot endpoint or bug fix.

Frequently Asked Questions about springboot-tdd

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

FAQPage Schema
How do I write unit tests for Spring Boot services with Mockito?

Use @ExtendWith(MockitoExtension.class) with @Mock for dependencies and @InjectMocks for the service under test. Stub with when(...).thenReturn(...) and verify interactions with verify(repo).save(any()), following the Arrange-Act-Assert pattern.

How to test Spring Boot REST controllers with MockMvc?

Use @WebMvcTest(YourController.class) with an autowired MockMvc and @MockBean for the service layer. Perform requests with mockMvc.perform(get("/api/...")) and assert responses using status().isOk() and jsonPath expressions.

What is the difference between @WebMvcTest and @SpringBootTest?

@WebMvcTest loads only the web layer with mocked services, making it fast for controller tests. @SpringBootTest boots the full application context for end-to-end integration tests, typically combined with @AutoConfigureMockMvc and a test profile.

How do I use Testcontainers with Spring Boot JPA tests?

Combine @DataJpaTest with @AutoConfigureTestDatabase(replace = Replace.NONE) and import a Testcontainers configuration class. Use @DynamicPropertySource to inject the container's JDBC URL into the Spring context so tests run against a real Postgres or Redis instance.

How do I enforce test coverage in Spring Boot with JaCoCo?

Add the jacoco-maven-plugin with the prepare-agent goal and a report execution bound to the verify phase. Run mvn verify or ./gradlew test jacocoTestReport to generate coverage reports and check them against your 80% target.