liveBook · Manning

Spring-boot-starter-test

As explained in Testing Spring Boot Applications

Spring Boot Starter Test is a Spring Boot starter dependency that aggregates common testing libraries and integrations for application tests.

spring-boot-starter-test is Spring Boot’s curated testing dependency. It bundles the core libraries, integrations, and annotation-driven tooling needed for most application tests, including test execution, assertions, mocking, and Spring test support. section 1.1 section 1.6

Choose the starter according to the application surface being tested:

  • Use spring-boot-starter-test for core Boot application testing without web capabilities. section 1.1
  • Use spring-boot-starter-webmvc-test or spring-boot-starter-webflux-test when web-specific testing support is required; each includes the core test starter. section 1.1
  • Use dedicated Spring portfolio test starters for areas such as REST clients, security, data, or batch processing. section 1.1
Listing 1.1 The spring-boot-starter-webmvc-test dependency in the pom.xml of a typical Boot project
<dependencies>
  <!-- ... -->
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webmvc-test</artifactId>
    <scope>test</scope> #1
  </dependency>
</dependencies>

Declare the testing starter with test scope so its dependencies remain available to test code rather than production code. section 1.1

Spring Boot’s testing machinery uses annotations to discover configuration, start the application before tests, synchronize its lifecycle with test classes, shut it down afterward, and perform cleanup. Tests can access beans with @Autowired, update configuration, and replace existing beans. This approach is useful for user scenarios that exercise the application as a whole, but it is heavier than focused unit testing and can become unwieldy for fine-grained conditional logic or state-heavy tests. section 1.1 section 1.6

How Testing Spring Boot Applications covers it

How deep it goes
Explains dependency choices, test scope, annotation-driven lifecycle, bean access, and trade-offs without detailing individual library internals.
Examples
Uses Maven test-scope dependencies, Spring Initializr-generated tests, @SpringBootTest, @Autowired, and replaceable application beans.
What it assumes
Assumes a Spring Boot project and distinguishes focused unit tests from application-level integration tests.
What you can do after
Apply Spring Boot’s curated testing stack to build lifecycle-managed application tests and select focused or web-specific starters.
How it connects
Connects Spring Boot testing with unit tests, integration tests, Spring annotations, application contexts, mocking, and web testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Testing Spring Boot Applications. The section links point to the parts of the book it draws on.