feat: add spring-boot-testing skill for Spring Boot 4.0#1085
Merged
aaronpowell merged 1 commit intogithub:stagedfrom Mar 19, 2026
Merged
feat: add spring-boot-testing skill for Spring Boot 4.0#1085aaronpowell merged 1 commit intogithub:stagedfrom
aaronpowell merged 1 commit intogithub:stagedfrom
Conversation
- 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.
Contributor
There was a problem hiding this comment.
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 aSKILL.mdentry 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.mdto 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` | |
Contributor
Author
|
@all-contributors add @kartikdhiman for skills instructions |
Contributor
|
I couldn't determine any contributions to add, did you specify any contributions? |
aaronpowell
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.Description
@WebMvcTest@DataJpaTest@RestClientTest@JsonTest@SpringBootTestType of Contribution
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.