Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
github avatar

Spring Boot Testing

  • 1.8k installs
  • 37.1k repo stars
  • Updated July 28, 2026
  • github/awesome-copilot

spring-boot-testing is an agent skill that Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.

About

The spring-boot-testing skill. Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ. **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 alternatives ## Which Test Slice?. **Analyze complexity** - If you need more than 5-7 test cases to cover a single method, it's likely too complex 2. **Recommend refactoring** - Suggest breaking the code into smaller, focused functions 3. The workflow follows the source SKILL.md contract with progressive reference loading, clear trigger phrases, and practical steps developers can apply directly in agent sessions. The workflow follows the source SKILL.md contract with progressive reference loading, clear trigger phrases, and practical steps developers can apply directly in agent sessions.

  • 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
  • [references/test-slices-overview.md](references/test-slices-overview.md) - Decision matrix and comparison

Spring Boot Testing by the numbers

  • 1,815 all-time installs (skills.sh)
  • +28 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #407 of 2,184 Testing & QA skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

spring-boot-testing capabilities & compatibility

Capabilities
test pyramid: unit (fast) > slice (focused) > in · right tool: use the narrowest slice that gives y · assertj style: fluent, readable assertions over · modern apis: prefer mockmvctester and resttestcl · [references/test slices overview.md](references/
Use cases
testing · debugging · ci cd
From the docs

What spring-boot-testing says it does

**Test Pyramid**: Unit (fast) > Slice (focused) > Integration (complete) 2.
SKILL.md
**Right Tool**: Use the narrowest slice that gives you confidence 3.
SKILL.md
npx skills add https://github.com/github/awesome-copilot --skill spring-boot-testing

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.8k
repo stars37.1k
Security audit3 / 3 scanners passed
Last updatedJuly 28, 2026
Repositorygithub/awesome-copilot

How do I apply spring-boot-testing correctly using the SKILL.md workflows and reference files?

Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.

Who is it for?

Developers and software engineers working with spring-boot-testing patterns from the skill documentation.

Skip if: Skip when cached docs are empty, boilerplate-only, or outside the skill documented scope.

When should I use this skill?

Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.

What you get

Grounded spring-boot-testing guidance with highlights, triggers, and evidence quotes from SKILL.md.

  • AssertJ assertion code snippets
  • readable test method examples

Files

SKILL.mdMarkdownGitHub ↗

Spring Boot Testing

This skill provides expert guide for testing Spring Boot 4 applications with modern patterns and best practices.

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 alternatives

Which Test Slice?

ScenarioAnnotationReference
Controller + HTTP semantics@WebMvcTestreferences/webmvctest.md
Repository + JPA queries@DataJpaTestreferences/datajpatest.md
REST client + external APIs@RestClientTestreferences/restclienttest.md
JSON (de)serialization@JsonTestreferences/test-slices-overview.md
Full application@SpringBootTestreferences/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:

1. Analyze complexity - If you need more than 5-7 test cases to cover a single method, it's likely too complex 2. Recommend refactoring - Suggest breaking the code into smaller, focused functions 3. User decision - If the user agrees to refactor, help identify extraction points 4. 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:

1. Main scenario - The happy path, most common use case 2. Other paths - Alternative valid scenarios, edge cases 3. 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: 1. Business-critical paths (payment processing, order validation) 2. Complex algorithms (pricing, discount calculations) 3. Error handling (exceptions, edge cases) 4. 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>

Related skills

Forks & variants (1)

Spring Boot Testing has 1 known copy in the catalog totaling 188 installs. They canonicalize to this original listing.

How it compares

Pick spring-boot-testing for AssertJ assertion syntax in Java Spring Boot tests rather than Mockito mocking or Testcontainers setup.

FAQ

Who is spring-boot-testing for?

Developers and software engineers working with spring-boot-testing patterns from the skill documentation.

When should I use 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.

Is spring-boot-testing safe to install?

Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.