第09课:WebFlux 集成测试及部署
前言
在日常工作中,免不了自测 UT,因为覆盖率不达标,是不允许提交测试,那怎么进行 WebFlux 项目的测试呢。@WebFluxTest 是 WebFlux 测试的重要注解。
结构
回到这个工程中,使用 springboot-webflux-3-mongodb 工程,工程如图:
目录核心如下:
- pom.xml 添加 Test 相关依赖;
- test / CityWebFluxControllerTest WebFlux API 测试类;
POM 依赖
pom.xml 添加对应的测试依赖:
<!-- Spring Boot Test 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>