github/awesome-copilot/spring-boot-testing
Claude Code and agent skill by github/awesome-copilot
- community
Checking that the SKILL.md file is still in the repository.
Expert Spring Boot testing specialist that selects the best testing techniques for your situation: test slices, Testcontainers with @ServiceConnection, Failsafe integration tests, MockitoBean, JUnit and AssertJ. Written for Spring Boot 4 with notes for Boot 3.
Install
npx vskill@latest install github/awesome-copilot/spring-boot-testingSKILL.md
Spring Boot Testing
This skill provides expert guidance for testing Spring Boot applications with modern patterns and best practices. Examples target Spring Boot 4; see the compatibility note below for Boot 3.
Compatibility: detect first
Read the project's Spring Boot version and test dependencies before writing tests, and do not upgrade them implicitly.
| Spring Boot 3.x | Spring Boot 4.x | ||
|---|---|---|---|
| JUnit | 5 (Jupiter) | 6 by default (same org.junit.jupiter.api annotations; JUnit 5 tests keep working) | |
| Mock beans | @MockitoBean / @MockitoSpyBean from 3.4 (Spring Framework 6.2); @MockBean / @SpyBean are deprecated | @MockitoBean replaces @MockBean (do not use the old ones) | |
| Test starters | spring-boot-starter-test covers everything | modular: add spring-boot-starter-webmvc-test, spring-boot-starter-data-jpa-test, ... | |
| Slice imports | org.springframework.boot.test.autoconfigure... | moved, e.g. org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest | |
| Testcontainers | 1.x names | 2.x names (testcontainers-postgresql) |
Details: references/sb4-migration.md, references/mockitobean.md.
Core Principles
- Test Pyramid: Unit (fast) > Slice (focused) > Integration (complete)
- Right Tool: Use the narrowest slice that gives you confidence
- AssertJ Style: Fluent, readable assertions over verbose matchers
- Modern APIs: Prefer MockMvcTester and RestTestClient over legacy alternatives
Which Test Slice?
| Scenario | Annotation | Reference | |
|---|---|---|---|
| Controller + HTTP semantics | @WebMvcTest | references/webmvctest.md | |
| Repository + JPA queries | @DataJpaTest | references/datajpatest.md | |
| REST client + external APIs | @RestClientTest | references/restclienttest.md | |
| JSON (de)serialization | @JsonTest | references/test-slices-overview.md | |
| Full application | @SpringBootTest | references/test-slices-overview.md |
Test Slices Reference
- references/test-slices-overview.md - Decision matrix and comparison
- references/webmvctest.md - Web layer with MockMvc
- references/datajpatest.md - Data layer with Testcontainers
- references/restclienttest.md - REST client testing
Testing Tools Reference
- references/mockmvc-tester.md - AssertJ-style MockMvc (3.2+)
- references/mockmvc-classic.md - Traditional MockMvc (pre-3.2)
- references/resttestclient.md - Spring Boot 4+ REST client
- references/mockitobean.md - Mocking dependencies
Assertion Libraries
- references/assertj-basics.md - Scalars, strings, booleans, dates
- references/assertj-collections.md - Lists, Sets, Maps, arrays
Testcontainers and integration tests
- references/testcontainers-jdbc.md -
@ServiceConnectionquickstart, PostgreSQL, MySQL, etc. - references/failsafe-integration-tests.md -
*ITclasses silently skipped unless Failsafe is bound; run./mvnw verify
Maven gotcha: Failsafe declared only in<pluginManagement>means*ITtests never run. Declare it in<build><plugins>with theintegration-testandverifygoals and run./mvnw verify.
Test Data Generation
- references/instancio.md - Generate complex test objects (3+ properties)
Performance & Migration
- references/context-caching.md - Speed up test suites
- references/sb4-migration.md - Spring Boot 4.0 changes
Quick Decision Tree
Spring Boot 4 Highlights
- RestTestClient: Modern alternative to TestRestTemplate
- @MockitoBean: Replaces @MockBean (deprecated)
- MockMvcTester: AssertJ-style assertions for web tests
- Modular starters: Technology-specific test starters
- Context pausing: Automatic pausing of cached contexts (Spring Framework 7)
Testing Best Practices
Code Complexity Assessment
When a method or class is too complex to test effectively:
- Analyze complexity - If you need more than 5-7 test cases to cover a single method, it's likely too complex
- Recommend refactoring - Suggest breaking the code into smaller, focused functions
- User decision - If the user agrees to refactor, help identify extraction points
- Proceed if needed - If the user decides to continue with the complex code, implement tests despite the difficulty
Example of refactoring recommendation:
Avoid Code Redundancy
Create helper methods for commonly used objects and mock setup to enhance readability and maintainability.
Test Organization with @DisplayName
Use descriptive display names to clarify test intent:
Test Coverage Order
Always structure tests in this order:
- Main scenario - The happy path, most common use case
- Other paths - Alternative valid scenarios, edge cases
- Exceptions/Errors - Invalid inputs, error conditions, failure modes
Test Production Scenarios
Write tests with real production scenarios in mind. This makes tests more relatable and helps understand code behavior in actual production cases.
Test Coverage Goals
Aim for 80% code coverage as a practical balance between quality and effort. Higher coverage is beneficial but not the only goal.
Use Jacoco maven plugin for coverage reporting and tracking.
Coverage Rules:
- 80+% coverage minimum
- Focus on meaningful assertions, not just execution
What to Prioritize:
- Business-critical paths (payment processing, order validation)
- Complex algorithms (pricing, discount calculations)
- Error handling (exceptions, edge cases)
- Integration points (external APIs, databases)
Dependencies (Spring Boot 4)
See also: <https://docs.spring.io/spring-boot/reference/testing/spring-boot-applications.html> and <https://docs.spring.io/spring-boot/reference/features/dev-services.html>.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/spring-boot-testing/SKILL.md
Popularity
- Repository stars
- 27,115
- Repository forks
- 3,145
- 7-day trend score
- 51
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 22 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/github/awesome-copilot/spring-boot-testing)