github/awesome-copilot / skills/spring-boot-testing
spring-boot-testing
VerifiedExpert 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.3 KB |
| references/assertj-basics.md | markdown | 4.3 KB |
| references/assertj-collections.md | markdown | 4.9 KB |
| references/context-caching.md | markdown | 2.4 KB |
| references/datajpatest.md | markdown | 5.0 KB |
| references/failsafe-integration-tests.md | markdown | 2.5 KB |
| references/instancio.md | markdown | 4.9 KB |
| references/mockitobean.md | markdown | 4.5 KB |
| references/mockmvc-classic.md | markdown | 5.8 KB |
| references/mockmvc-tester.md | markdown | 7.5 KB |
| references/restclienttest.md | markdown | 4.6 KB |
| references/resttestclient.md | markdown | 4.9 KB |
| references/sb4-migration.md | markdown | 3.3 KB |
| references/test-slices-overview.md | markdown | 5.5 KB |
| references/testcontainers-jdbc.md | markdown | 7.7 KB |
| references/webmvctest.md | markdown | 3.6 KB |
references/failsafe-integration-tests.md
View on GitHub# Failsafe: running `*IT` integration tests (Maven)
## The gotcha
Surefire runs `*Test`, `Test*`, `*Tests`, `*TestCase`. Classes named `*IT` / `IT*` / `*ITCase` are run by **maven-failsafe-plugin**. If Failsafe is only declared in `<pluginManagement>` (or not at all), it is never bound to the lifecycle: `*IT` classes compile but **silently never run**, and `./mvnw test` or `./mvnw package` still reports success.
Spring Boot's parent POM configures Failsafe in `<pluginManagement>` (with the `integration-test` and `verify` goals) but does **not** activate it.
## Fix
Declare the plugin in `<build><plugins>` and bind the goals:
```xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
```
The version is managed by `spring-boot-starter-parent`; if the project does not use it, pin one explicitly.
## Run and verify
```bash
./mvnw verify
```
`verify` runs `integration-test` and then `verify` (which fails the build on IT failures). Do not use `./mvnw test` or `package` for ITs, and do not use `integration-test` alone: failures would not fail the build.
Confirm they ran: the output must contain a `failsafe:<version>:integration-test` line (Maven 3.10 prints `--- failsafe:3.5.6:integration-test (default)`; older Maven prints `maven-failsafe-plugin:...`) and `Tests run: N` for your `*IT` classes (also look in `target/failsafe-reports/`). If N is 0 or the plugin line is missing, the binding is absent.
## Alternatives
- Name integration tests `*Test` and run them with Surefire (simplest; no split).
- Gradle has no such issue: put them in `test`, or define a separate suite (JVM Test Suite plugin, verified with Boot 4.1; sources in `src/integrationTest/java`, a failing test fails `./gradlew build`):
```groovy
plugins { id 'jvm-test-suite' }
testing {
suites {
integrationTest(JvmTestSuite) {
useJUnitJupiter()
dependencies {
implementation project()
implementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
}
targets { all { testTask.configure { shouldRunAfter(test) } } }
}
}
}
tasks.named('check') { dependsOn testing.suites.integrationTest }
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |