S
spring-testing-fundamentals
About spring-testing-fundamentals
A skill for Spring developers covering general testing practices with AssertJ, Mockito, and JUnit 5. It also guides test-slice selection, context caching, and Boot 4 annotation migration.
Key features
- 01AssertJ assertion patterns
- 02Mockito stubbing and verification
- 03ArgumentCaptor usage
- 04Test-slice selection guidance
- 05Context caching and @DirtiesContext
- 06Boot 4 annotation migration
Use cases
- 01Writing unit tests for Spring applications
- 02Choosing a Spring test-slice annotation
- 03Investigating slow tests caused by context caching
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ spring-ai-community/ spring-testing-skills --skill spring-testing-fundamentalsAfter installing, type/spring-testing-fundamentalsin Claude Code to confirm it loaded.
Bundled filesreferences/assertj-mockito-idioms.mdreferences/cross-cutting-testing-patterns.md
Details
From the project READMESpring Testing Fundamentals
Signals: assertThat, assertThatThrownBy, given/willReturn, then(mock).should, ArgumentCaptor, @MockitoBean, @MockitoSpyBean, @DirtiesContext, context caching, testing pyramid
Tested With
- Spring Boot 3.2+ / Spring Boot 4.x
- Spring Framework 6.x / Spring Framework 7.x
- AssertJ 3.24+
- Mockito 5.x
- JUnit 5
Do NOT Use This Skill When
You need domain-specific patterns:
- Testing JPA repositories, Testcontainers,
@DataJpaTest→ usespring-jpa-testing - Testing REST controllers, MockMvc,
@WebMvcTest→ usespring-mvc-testing - Testing security,
@WithMockUser, JWT, OAuth2 → usespring-security-testing - Testing reactive controllers,
@WebFluxTest,StepVerifier→ usespring-webflux-testing - Testing WebSocket/STOMP → use
spring-websocket-testing
When to Read References
| Situation | Read |
|---|---|
| AssertJ scalars, optionals, BigDecimal, collections, exceptions | references/assertj-mockito-idioms.md |
BDDMockito given/willReturn, then(mock).should, argument matchers | references/assertj-mockito-idioms.md |
ArgumentCaptor usage and verification patterns | references/assertj-mockito-idioms.md |
UnnecessaryStubbingException and strict stubbing fixes | references/assertj-mockito-idioms.md |
@MockitoBean vs @MockitoSpyBean in Boot 4 | references/assertj-mockito-idioms.md |
| Testing pyramid: when to use each slice annotation | references/cross-cutting-testing-patterns.md |
Context caching: why tests are slow, cache key, @DirtiesContext impact | references/cross-cutting-testing-patterns.md |
| Universal anti-patterns across all Spring test types | references/cross-cutting-testing-patterns.md |
| Boot 4 annotation migration checklist | references/cross-cutting-testing-patterns.md |
Comments
Markdown supported