This page covers how tests are configured and executed across the Spring Boot multi-project build: the JVM settings and ordering applied uniformly to all Test tasks, the SystemTestPlugin that provisions a dedicated source set for system tests, the shared test support libraries, and the build-level plugins that enforce and document test slice annotations. For coverage of the smoke test and system test suites themselves, see 5.3. For Checkstyle and Kotlin static analysis, see 5.2.
Every subproject in the Spring Boot build applies the ConventionsPlugin via the org.springframework.boot.conventions Gradle plugin ID. That plugin delegates to JavaConventions, which is the single place where all Test task behavior is centrally configured. Specialized plugins registered in buildSrc extend this baseline for specific test categories.
Diagram: Plugin hierarchy for test configuration
Sources: buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java42-59 buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java207-219 buildSrc/build.gradle134-173
JavaConventions.configureTestConventions() is invoked on every project that applies the JavaBasePlugin. It uses project.getTasks().withType(Test.class, ...) to apply the following settings to all Test task instances, including custom source sets like integrationTest or systemTest.
| Setting | Value | Method |
|---|---|---|
| Test framework | JUnit Platform | test.useJUnitPlatform() |
| Max JVM heap | 1536 MB | test.setMaxHeapSize("1536M") |
| Task ordering | Must run after Checkstyle and CheckFormat tasks | test::mustRunAfter |
| Retry count (CI) | 3 | TestRetryConfiguration.getMaxRetries() |
| Retry count (local) | 0 | TestRetryConfiguration.getMaxRetries() |
| Fail on pass after retry | false | TestRetryConfiguration.getFailOnPassedAfterRetry() |
| Predictive test selection | Enabled if ENABLE_PREDICTIVE_TEST_SELECTION=true | PredictiveTestSelectionConfiguration.getEnabled() |
Additionally, for any project with JavaPlugin applied, a testRuntimeOnly dependency on org.junit.platform:junit-platform-launcher is added automatically.
Sources: buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java207-244
Retry behavior is controlled via the Develocity agent's DevelocityTestConfiguration extension. The isCi() method checks the CI environment variable (Boolean.parseBoolean(System.getenv("CI"))).
CI=true): up to 3 retries per test, failOnPassedAfterRetry set to false.CI unset or any other value): 0 retries.This logic is tested in ConventionsPluginTests:
testRetryIsConfiguredWithThreeRetriesOnCI passes CI=true in the environment and asserts maxRetries: 3.testRetryIsConfiguredWithZeroRetriesLocally passes CI=local and asserts maxRetries: 0.Sources: buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java221-244 buildSrc/src/test/java/org/springframework/boot/build/ConventionsPluginTests.java183-225
When the ENABLE_PREDICTIVE_TEST_SELECTION environment variable is true, the Develocity PredictiveTestSelectionConfiguration.getEnabled() convention is set to true on every Test task. This allows Develocity to skip tests predicted to be unaffected by recent changes.
Sources: buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java233-244
SystemTestPlugin (plugin ID: org.springframework.boot.system-test) creates a dedicated systemTest source set and a corresponding systemTest test task in any project that applies it alongside the JavaPlugin.
Diagram: SystemTestPlugin source set and task wiring
Sources: buildSrc/src/main/java/org/springframework/boot/build/test/SystemTestPlugin.java39-100
systemTest source set inherits the main source set's output on both the compile and runtime classpaths.systemTest task is placed in Gradle's verification lifecycle group.System.getenv("CI") returns "true"), the task's outputs are marked as never up-to-date and are excluded from the build cache. This ensures system tests always run fresh in CI environments.EclipsePlugin is present, the systemTest runtime classpath configuration is added to the Eclipse classpath via eclipse.classpath.plusConfigurations.Sources: buildSrc/src/main/java/org/springframework/boot/build/test/SystemTestPlugin.java54-100
The build declares three dedicated test support libraries in settings.gradle under the test-support: group. These are internal libraries that other subprojects depend on in their testImplementation or integrationTestImplementation configurations.
| Module | Path in settings.gradle | Purpose |
|---|---|---|
spring-boot-test-support | test-support:spring-boot-test-support | Base test utilities shared across the core modules |
spring-boot-docker-test-support | test-support:spring-boot-docker-test-support | Helpers for tests that require a Docker daemon |
spring-boot-gradle-test-support | test-support:spring-boot-gradle-test-support | Helpers for testing Gradle plugins using GradleRunner |
Sources: settings.gradle63-65
This module is used in tests that exercise the Gradle plugin, such as ConventionsPluginTests, which uses GradleRunner from the Gradle TestKit to spin up isolated Gradle builds. The runner is configured with withPluginClasspath() to inject the buildSrc plugin classes into the test build.
Sources: buildSrc/src/test/java/org/springframework/boot/build/ConventionsPluginTests.java227-238
Several plugins in buildSrc handle test infrastructure beyond task configuration. These are registered in buildSrc/build.gradle and are available to any subproject.
Diagram: Test-related custom Gradle plugins registered in buildSrc
Sources: buildSrc/build.gradle133-173
Registered as org.springframework.boot.test-failures, class TestFailuresPlugin. Applied by JavaConventions to every project with JavaBasePlugin. Handles aggregation or reporting of test failures across the build.
Sources: buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java150 buildSrc/build.gradle165-168
Registered as org.springframework.boot.test-auto-configuration, class TestAutoConfigurationPlugin. Applied to modules that expose test auto-configuration. It validates that the META-INF/spring/ import files for auto-configuration correctly reference classes that exist on the classpath. This is the test-side counterpart to the AutoConfigurationPlugin.
Sources: buildSrc/build.gradle161-164
Registered as org.springframework.boot.test-slice, class TestSlicePlugin. Applied to the spring-boot-test-autoconfigure module (and similar) to validate that each @...Test slice annotation's associated import file (e.g., META-INF/spring/... files) correctly maps to real configuration classes.
Sources: buildSrc/build.gradle169-172
DockerTestPlugin (org.springframework.boot.docker-test): configures a dockerTest source set for tests that require Docker. Used by modules such as spring-boot-docker-test-support.IntegrationTestPlugin (org.springframework.boot.integration-test): configures an integrationTest source set. Integration test subprojects under :integration-test: use this.Sources: buildSrc/build.gradle133-140
Diagram: Full test configuration flow from ConventionsPlugin to execution
Sources: buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java42-59 buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java148-219 buildSrc/src/main/java/org/springframework/boot/build/test/SystemTestPlugin.java39-100 buildSrc/build.gradle161-173
Refresh this wiki