spring-boot-test-patterns

Installation
Summary

Comprehensive testing patterns for Spring Boot applications covering unit, slice, integration, and container-based tests.

  • Covers four test types with performance targets: unit tests (< 50ms), slice tests (< 100ms), integration tests (< 500ms), and full context tests with Testcontainers
  • Includes patterns for Mockito-based unit testing, JPA/MVC slice testing with focused Spring contexts, and REST API testing with MockMvc and WebTestClient
  • Demonstrates Spring Boot 3.5+ @ServiceConnection for cleaner container management and @DynamicPropertySource for dynamic property registration
  • Provides context caching strategies, container reuse patterns, and CI/CD configuration examples for GitHub Actions and Docker Compose
SKILL.md

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 @WebMvcTest or MockMvc
  • Configuring @ServiceConnection for 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 @DataJpaTest < 100ms Database operations with minimal context
Related skills

More from giuseppe-trisciuoglio/developer-kit

Installs
1.1K
GitHub Stars
246
First Seen
Feb 3, 2026