Spring Testing

Standardizes unit and integration testing for Spring Boot using JUnit 5, Mockito, and TestContainers.

Updated May 12, 2026
One-click install
npx skills add https://github.com/ZzZueszZ/claude-kit --skill spring-testing-zzzueszz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: Spring Testing
Source: https://github.com/ZzZueszZ/claude-kit/tree/main/.claude/skills/spring-testing
Command: npx skills add https://github.com/ZzZueszZ/claude-kit --skill spring-testing-zzzueszz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent, high-quality tests in Spring Boot projects is often inconsistent across teams, leading to poor coverage, slow test suites, and missed error cases. This Skill provides standardized patterns and templates for unit and integration tests. ## Core Features & Use Cases - Unit Test Templates: Ready-to-use patterns for Service layer tests with Mockito and Controller layer tests with @WebMvcTest and MockMvc. - Integration Test Patterns: Repository tests with @DataJpaTest and full-stack tests with @SpringBootTest, both backed by TestContainers and PostgreSQL. - Best Practices & Checklists: Naming conventions, Given-When-Then structure, AssertJ assertions, coverage targets, and a pre-commit checklist. - Use Case: When implementing a new UserService method, ask for tests and receive a complete test class covering happy path, not-found, duplicate, and validation scenarios following team conventions. ## Quick Start Write unit and integration tests for my Spring Boot UserService and UserController following the spring-testing standards.

Frequently Asked Questions about Spring Testing

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

FAQPage Schema
How do I write unit tests for a Spring Boot Service layer?▼

Use @ExtendWith(MockitoExtension.class) with @Mock for dependencies and @InjectMocks for the service under test, never @SpringBootTest. Structure each test with Given-When-Then, use AssertJ assertions, and verify mock interactions with verify().

How to test Spring Boot controllers with MockMvc?▼

Use @WebMvcTest targeting the specific controller with @MockBean for the service layer. Perform requests with MockMvc and assert status codes and JSON fields using jsonPath, covering success, validation error, and not-found cases.

Should I use @SpringBootTest or Mockito for unit tests?▼

Use Mockito with @ExtendWith(MockitoExtension.class) for unit tests because @SpringBootTest loads the full application context and is too slow. Reserve @SpringBootTest for full-stack integration tests with TestContainers.

How do I test JPA repositories with a real database?▼

Use @DataJpaTest combined with TestContainers and a PostgreSQLContainer, wiring the container's JDBC URL via @DynamicPropertySource. Set AutoConfigureTestDatabase.Replace.NONE so tests run against the real container database instead of an embedded one.

What test coverage is recommended for Spring Boot services?▼

Aim for at least 80% line coverage on the Service layer and 90% on critical business logic. Controller tests should cover all endpoints plus validation and error cases, including happy path, not-found, and duplicate scenarios.