spring-boot-test-patterns
Spring Boot Test Patterns guides you through layered testing strategies—from fast unit tests with mocked dependencies to full integration tests with real databases via Testcontainers. Learn focused slice testing with @DataJpaTest and @WebMvcTest, REST API testing with MockMvc, and container setup using @ServiceConnection for Spring Boot 3.5+.
Spring Boot Test Patterns provides comprehensive guidance for writing unit, integration, and slice tests using JUnit 5, Mockito, and Testcontainers.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-06-22
Spring Boot Test Patterns provides comprehensive guidance for writing unit, integration, and slice tests using JUnit 5, Mockito, and Testcontainers. Spring Boot Test Patterns guides you through layered testing strategies—from fast unit tests with mocked dependencies to full integration tests with real databases via Testcontainers. Learn focused slice testing with @DataJpaTest and @WebMvcTest, REST API testing with MockMvc, and container setup using @ServiceConnection for Spring Boot 3.5+.
Use it when
- Spring Boot Test Patterns shows how to combine JUnit 5 with Mockito for effective testing.
- Spring Boot Test Patterns covers Testcontainers setup for database testing in Spring Boot 3.5+.
Verify before relying
Read SKILL.md below before installing (9 files). Open directory: indexed for reading, not audited.
Install
giuseppe-trisciuoglio/developer-kit/spring-boot-test-patterns · repository language: Python
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What are spring boot testing patterns?
Spring Boot Test Patterns teaches layered testing strategies for Spring Boot applications. It covers unit tests with mocked dependencies, integration tests using Testcontainers for real databases, and focused slice tests via @DataJpaTest and @WebMvcTest. The guide emphasizes test isolation, performance optimization, and REST API testing with MockMvc to help you build comprehensive test suites efficiently.
How do I write spring boot tests with JUnit 5 and Mockito?
Spring Boot Test Patterns shows how to combine JUnit 5 with Mockito for effective testing. Use @Mock for dependencies, @InjectMocks for the class under test, and @ExtendWith(MockitoExtension.class) for annotation support. The guide demonstrates unit test examples, mocking strategies with @MockBean for Spring beans, and integration patterns that layer unit and integration tests for comprehensive coverage.
How do I configure Testcontainers and @ServiceConnection?
Spring Boot Test Patterns covers Testcontainers setup for database testing in Spring Boot 3.5+. Use @ServiceConnection to automatically wire container connections into your application context—no manual URL configuration needed. The guide includes Postgres container examples, shows how @ServiceConnection eliminates boilerplate, and demonstrates integrating Testcontainers with @SpringBootTest for realistic integration tests.
What is @DataJpaTest and @WebMvcTest for slice testing?
Spring Boot Test Patterns explains slice testing patterns using @DataJpaTest for repository testing and @WebMvcTest for controller testing. These annotations load only relevant beans, reducing context rebuild overhead and speeding up test execution. The guide shows repository testing examples, MockMvc usage for REST endpoint validation, and how slice tests isolate layers for faster, focused testing.
How can I optimize spring boot test performance?
Spring Boot Test Patterns addresses test performance optimization by reducing context rebuild overhead through slice testing (@DataJpaTest, @WebMvcTest), reusing application contexts across tests, and leveraging @ServiceConnection to simplify container setup. The guide covers test isolation strategies, CI/CD pipeline integration for automated test execution, and best practices for maintaining fast feedback loops in your test suite.
How do I test Spring Boot REST APIs with MockMvc?
Spring Boot Test Patterns demonstrates REST API testing using MockMvc within @WebMvcTest slices. Learn to mock controller dependencies, perform HTTP requests (GET, POST, PUT, DELETE), validate response status and content, and test error scenarios. The guide includes practical examples of controller testing patterns and shows how @WebMvcTest provides a focused testing environment without loading unnecessary beans.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Spring Boot Testing Patterns
Overview
Comprehensive guidance for writing robust test suites for Spring Boot applications using JUnit 5, Mockito, Testcontainers, and performance-optimized slice testing patterns.
When to Use
- Writing unit tests for services or repositories with mocked dependencies
- Implementing integration tests with real databases via Testcontainers
- Testing REST APIs with
@WebMvcTestor MockMvc - Configuring
@ServiceConnectionfor container management in Spring Boot 3.5+
Quick Reference
| Test Type | Annotation | Target Time | Use Case |
|---|---|---|---|
| Unit Tests | @ExtendWith(MockitoExtension.class) |
< 50ms | Business logic without Spring context |
| Repository Tests |
(truncated - see the full file via the links below)
File tree — 9 files
plugins/developer-kit-java/skills/spring-boot-test-patterns/SKILL.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/api-reference.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/best-practices.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/ci-cd-configuration.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/slice-testing.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/test-dependencies.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/testcontainers-setup.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/unit-testing.md
plugins/developer-kit-java/skills/spring-boot-test-patterns/references/workflow-patterns.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Write comprehensive unit and integration tests for Spring Boot applications”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Master test-driven development for Spring Boot services targeting 80%+ code coverage. This skill covers the complete TDD cycle—writing failing tests first, implementing minimal code to pass, refactoring safely, and enforcing coverage with JaCoCo. Learn unit testing with JUnit 5 and Mockito, web layer testing with MockMvc, integration testing with SpringBootTest, and persistence layer testing with DataJpaTest and Testcontainers.
Build reliable unit tests for Java applications using JUnit 5, Mockito, and AssertJ with support for mocking, parameterized tests, and fluent assertions. Includes integration testing patterns with Testcontainers and Spring Boot Test, plus TDD and test coverage best practices to improve code quality.
Master enterprise Spring Boot development with guides covering project setup, entity models, repositories, service layers, REST controllers, and security. Learn proper patterns for dependency injection, data persistence, and API design while following Spring conventions and best practices.
Learn idiomatic Spring Boot 3.x patterns grounded in auto-configuration, constructor injection, and actuator-driven observability. Covers dependency injection best practices, Spring Data JPA query methods and projections, REST controller design with DTOs, and structured logging for production readiness. Includes testing patterns for integration and controller slices.
Learn to unit test Spring REST controllers using MockMvc with mocked service dependencies. This skill covers testing HTTP methods, validating responses with JsonPath, handling errors, checking headers, and verifying content negotiation—all with focused examples for GET, POST, PUT, and DELETE endpoints.
This skill guides you through compiling Java applications ahead-of-time into native binaries using GraalVM, eliminating JVM startup overhead and slashing memory consumption. It covers build tool setup for Maven and Gradle, framework-specific patterns for Spring Boot, Quarkus, and Micronaut, metadata management for reflection and resources, and an iterative debugging workflow to resolve native build failures.
More skills spring-boot-project-creator (MIT) · spring-boot-engineer (MIT) · unit-test-application-events (MIT) · spring-boot-actuator (MIT) · java-architect (MIT) · unit-test-boundary-conditions (MIT) · Python Micrometer Metrics Setup (unlicensed) · unit-test-service-layer (MIT)