Skip to content

feat: add spring-boot-testing skill for Spring Boot 4.0#1085

Merged
aaronpowell merged 1 commit intogithub:stagedfrom
kartikdhiman:add-springboot-testing-skill
Mar 19, 2026
Merged

feat: add spring-boot-testing skill for Spring Boot 4.0#1085
aaronpowell merged 1 commit intogithub:stagedfrom
kartikdhiman:add-springboot-testing-skill

Conversation

@kartikdhiman
Copy link
Contributor

  • Introduced MockMvcTester for AssertJ-style assertions in Spring MVC testing.
  • Added @restclienttest for testing REST clients with MockRestServiceServer.
  • Implemented RestTestClient as a modern alternative to TestRestTemplate.
  • Documented migration steps from Spring Boot 3.x to 4.0, including dependency and annotation changes.
  • Created an overview of test slices to guide testing strategies.
  • Included Testcontainers setup for JDBC testing with PostgreSQL and MySQL.
  • Enhanced @WebMvcTest documentation with examples for various HTTP methods and validation.

Pull Request Checklist

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have read and followed the Guidance for submissions involving paid services.
  • My contribution adds a new instruction, prompt, agent, skill, or workflow file in the correct directory.
  • The file follows the required naming convention.
  • The content is clearly structured and follows the example format.
  • I have tested my instructions, prompt, agent, skill, or workflow with GitHub Copilot.
  • I have run npm start and verified that README.md is up to date.

Description

  • New skill: spring-boot-testing
  • Practical decision guidance for selecting test slices:
    • @WebMvcTest
    • @DataJpaTest
    • @RestClientTest
    • @JsonTest
    • @SpringBootTest
  • Reference-driven structure with links for:
    • test slices
    • testing tools (MockMvcTester, RestTestClient, @MockitoBean)
    • AssertJ patterns
    • Testcontainers
    • test data generation
    • performance/context caching and Spring Boot 4 migration
  • Recommended testing workflow and coverage priorities for real-world scenarios

Type of Contribution

  • New instruction file.
  • New prompt file.
  • New agent file.
  • New plugin.
  • New skill file.
  • New agentic workflow.
  • Update to existing instruction, prompt, agent, plugin, skill, or workflow.
  • Other (please specify):

Additional Notes


By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.

- Introduced MockMvcTester for AssertJ-style assertions in Spring MVC testing.
- Added @restclienttest for testing REST clients with MockRestServiceServer.
- Implemented RestTestClient as a modern alternative to TestRestTemplate.
- Documented migration steps from Spring Boot 3.x to 4.0, including dependency and annotation changes.
- Created an overview of test slices to guide testing strategies.
- Included Testcontainers setup for JDBC testing with PostgreSQL and MySQL.
- Enhanced @WebMvcTest documentation with examples for various HTTP methods and validation.
Copilot AI review requested due to automatic review settings March 19, 2026 08:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new spring-boot-testing skill to the repository to provide reference-driven guidance for testing Spring Boot 4 applications, including test slices, modern Spring testing APIs, Testcontainers usage, and migration notes.

Changes:

  • Introduces the new skills/spring-boot-testing/ skill with a SKILL.md entry point and a set of focused reference pages.
  • Documents Spring MVC testing patterns (MockMvcTester / classic MockMvc), REST client testing (@restclienttest, RestTestClient), and data layer testing (@DataJpaTest + Testcontainers).
  • Updates docs/README.skills.md to register the new skill and list its reference files.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
skills/spring-boot-testing/SKILL.md Skill entry point and index of references, principles, and dependency snippets
skills/spring-boot-testing/references/webmvctest.md @WebMvcTest slice guidance and example patterns
skills/spring-boot-testing/references/testcontainers-jdbc.md Testcontainers JDBC setup patterns for real DB testing
skills/spring-boot-testing/references/test-slices-overview.md Decision matrix and quick selection guide for test slices
skills/spring-boot-testing/references/sb4-migration.md Migration-oriented notes for Spring Boot 4 testing changes
skills/spring-boot-testing/references/resttestclient.md RestTestClient reference and migration examples
skills/spring-boot-testing/references/restclienttest.md @RestClientTest patterns with MockRestServiceServer
skills/spring-boot-testing/references/mockmvc-tester.md MockMvcTester fluent assertion patterns
skills/spring-boot-testing/references/mockmvc-classic.md Legacy MockMvc patterns and migration pointers
skills/spring-boot-testing/references/mockitobean.md @MockitoBean usage patterns and migration from @MockBean
skills/spring-boot-testing/references/instancio.md Instancio-based test data generation patterns
skills/spring-boot-testing/references/datajpatest.md @DataJpaTest slice patterns including Testcontainers usage
skills/spring-boot-testing/references/context-caching.md TestContext caching concepts and performance tips
skills/spring-boot-testing/references/assertj-collections.md AssertJ collection assertion cookbook
skills/spring-boot-testing/references/assertj-basics.md AssertJ core assertion patterns and exception assertions
docs/README.skills.md Registers the new skill in the repo’s skill index

You can also share your feedback on Copilot code review. Take the survey.

}

@Test
void anonymousUserShouldBeForbidden() {
Comment on lines +110 to +121
restClient
.get()
.uri("/orders/1")
.exchange()
.expectStatus()
.isOk() // 200
.isCreated() // 201
.isNoContent() // 204
.isBadRequest() // 400
.isNotFound() // 404
.is5xxServerError() // 5xx
.isEqualTo(200); // Specific code
Comment on lines +112 to +126
## Testcontainers 2.0

Module naming changed:

**Before (1.x):**

```xml
<artifactId>postgresql</artifactId>
```

**After (2.0):**

```xml
<artifactId>testcontainers-postgresql</artifactId>
```
Comment on lines +114 to +121
## Java 25 Features in Tests

### Records for Test Data

```java
record OrderRequest(String product, int quantity) {}
record OrderResponse(Long id, String status, BigDecimal total) {}
```
@@ -0,0 +1,189 @@
---
name: spring-boot-testing
description: Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.
Comment on lines +176 to +195
```xml
<!-- WebMvcTest -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>

<!-- DataJpaTest -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<!-- RestClientTest -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-restclient-test</artifactId>
<scope>test</scope>
</dependency>
3. Clear() the entity manager to test lazy loading
4. Use real database (Testcontainers) for accurate results
5. Test both success and failure cases
6. Leverage Java 25 var keyword for cleaner variable declarations
Comment on lines +13 to +23
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-postgresql</artifactId>
<scope>test</scope>
</dependency>
@@ -0,0 +1,189 @@
---
name: spring-boot-testing
description: Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.
| [shuffle-json-data](../skills/shuffle-json-data/SKILL.md) | Shuffle repetitive JSON objects safely by validating schema consistency before randomising entries. | None |
| [snowflake-semanticview](../skills/snowflake-semanticview/SKILL.md) | Create, alter, and validate Snowflake semantic views using Snowflake CLI (snow). Use when asked to build or troubleshoot semantic views/semantic layer definitions with CREATE/ALTER SEMANTIC VIEW, to validate semantic-view DDL against Snowflake via CLI, or to guide Snowflake CLI installation and connection setup. | None |
| [sponsor-finder](../skills/sponsor-finder/SKILL.md) | Find which of a GitHub repository's dependencies are sponsorable via GitHub Sponsors. Uses deps.dev API for dependency resolution across npm, PyPI, Cargo, Go, RubyGems, Maven, and NuGet. Checks npm funding metadata, FUNDING.yml files, and web search. Verifies every link. Shows direct and transitive dependencies with OSSF Scorecard health data. Invoke with /sponsor followed by a GitHub owner/repo (e.g. "/sponsor expressjs/express"). | None |
| [spring-boot-testing](../skills/spring-boot-testing/SKILL.md) | Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ. | `references/assertj-basics.md`<br />`references/assertj-collections.md`<br />`references/context-caching.md`<br />`references/datajpatest.md`<br />`references/instancio.md`<br />`references/mockitobean.md`<br />`references/mockmvc-classic.md`<br />`references/mockmvc-tester.md`<br />`references/restclienttest.md`<br />`references/resttestclient.md`<br />`references/sb4-migration.md`<br />`references/test-slices-overview.md`<br />`references/testcontainers-jdbc.md`<br />`references/webmvctest.md` |
@kartikdhiman
Copy link
Contributor Author

@all-contributors add @kartikdhiman for skills instructions

@allcontributors
Copy link
Contributor

@kartikdhiman

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

@aaronpowell aaronpowell merged commit e4fc57f into github:staged Mar 19, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants