spring-boot-starter-webmvc-test is a Spring Boot testing starter for MVC applications. It includes the core spring-boot-starter-test dependencies plus MVC-specific testing support, while remaining restricted to test code through test scope. 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>
A typical Maven dependency declaration places the starter in test scope, preventing its testing-only dependencies from entering production code. section 1.1
Use the starter according to the application’s web stack:
- Choose webmvc-test for Spring MVC applications, typically created with the Spring Web selection and backed by a Servlet container. section 1.1
- Choose webflux-test instead for WebFlux applications using the reactive stack. section 1.1
- Treat the starter as declarative test infrastructure: annotations such as @SpringBootTest let Spring’s testing machinery discover configuration and manage application startup. section 1.1
