github/awesome-copilot/skills/spring-boot-testing/SKILL.md
spring-boot-testing
Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.
- Source repository stars
- 37,126
- Declared platforms
- 0
- Static risk flags
- 0
- Last source update
- 2026-07-28
- Source checked
- 2026-07-28
Decision brief
What it does—and where it fits
This skill provides expert guide for testing Spring Boot 4 applications with modern patterns and best practices.
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/github/awesome-copilot --skill "skills/spring-boot-testing"Inspect the Agent Skill "spring-boot-testing" from https://github.com/github/awesome-copilot/blob/9933dcad5be5caeb288cebcd370eeeb2fc2f1685/skills/spring-boot-testing/SKILL.md at commit 9933dcad5be5caeb288cebcd370eeeb2fc2f1685. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
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 complexRecommend refactoring - Suggest breaking the code into smaller, focused functionsUser decision - If the user agrees to refactor, help identify extraction points - 02
Core Principles
1. Test Pyramid: Unit (fast) Slice (focused) Integration (complete) 2. Right Tool: Use the narrowest slice that gives you confidence 3. AssertJ Style: Fluent, readable assertions over verbose matchers 4. Modern APIs: Prefer MockMvcTester and RestTestClient over legacy alternativ…
Test Pyramid: Unit (fast) Slice (focused) Integration (complete)Right Tool: Use the narrowest slice that gives you confidenceAssertJ Style: Fluent, readable assertions over verbose matchers - 03
Which Test Slice?
Review the “Which Test Slice?” section in the pinned source before continuing.
Review and apply the “Which Test Slice?” source section. - 04
Test Slices Reference
references/test-slices-overview.md - Decision matrix and comparison
references/test-slices-overview.md - Decision matrix and comparisonreferences/webmvctest.md - Web layer with MockMvcreferences/datajpatest.md - Data layer with Testcontainers - 05
Testing Tools Reference
references/mockmvc-tester.md - AssertJ-style MockMvc (3.2+)
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
Permission review
Static risk signals and limitations
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 87/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 37,126 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- github/awesome-copilot
- Skill path
- skills/spring-boot-testing/SKILL.md
- Commit
- 9933dcad5be5caeb288cebcd370eeeb2fc2f1685
- License
- MIT
- Collected
- 2026-07-28
- Default branch
- main
View the original SKILL.md
Spring Boot Testing
This skill provides expert guide for testing Spring Boot 4 applications with modern patterns and best practices.
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
- references/testcontainers-jdbc.md - PostgreSQL, MySQL, etc.
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
Testing a controller endpoint?
Yes → @WebMvcTest with MockMvcTester
Testing repository queries?
Yes → @DataJpaTest with Testcontainers (real DB)
Testing business logic in service?
Yes → Plain JUnit + Mockito (no Spring context)
Testing external API client?
Yes → @RestClientTest with MockRestServiceServer
Testing JSON mapping?
Yes → @JsonTest
Need full integration test?
Yes → @SpringBootTest with minimal context config
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:
// Before: Complex method hard to test
public Order processOrder(OrderRequest request) {
// Validation, discount calculation, payment, inventory, notification...
// 50+ lines of mixed concerns
}
// After: Refactored into testable units
public Order processOrder(OrderRequest request) {
validateOrder(request);
var order = createOrder(request);
applyDiscount(order);
processPayment(order);
updateInventory(order);
sendNotification(order);
return order;
}
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
@DisplayName("Should calculate discount for VIP customer")
void shouldCalculateDiscountForVip() { }
@Test
@DisplayName("Should reject order when customer has insufficient credit")
void shouldRejectOrderForInsufficientCredit() { }
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)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- For WebMvc tests -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<!-- For Testcontainers -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
Alternatives
Compare before choosing
coreyhaines31/marketingskills
ab-testing
When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program
event4u-app/agent-config
testing-anti-patterns
Use BEFORE writing/changing tests, adding mocks, or test-only methods on production classes — vs mocking-the-mock, production pollution, partial mocks, and overfit/tautological assertions
event4u-app/agent-config
design-review
Use when the user says "review the design", "check the UI", or wants a comprehensive UI/UX review. Uses a 7-phase methodology covering interaction, responsiveness, accessibility, and more.
event4u-app/agent-config
pest-testing
Use when writing, generating, or improving Pest tests for Laravel — clear intent, good coverage, maintainable structure, and alignment with project testing conventions.