|
此版本仍在开发中,尚未视为稳定版。如需最新稳定版本,请使用 Spring Boot 4.0.4! |
测试
Spring Boot 提供了多种工具和注解,以帮助您测试应用程序。
测试支持由两个模块提供:spring-boot-test 包含核心组件,而 spring-boot-test-autoconfigure 支持测试的自动配置。
大多数开发者使用 spring-boot-starter-test 起步依赖,它会导入 Spring Boot 的测试模块以及 JUnit Jupiter、AssertJ、Hamcrest 和许多其他有用的库。
|
如果你有使用 JUnit 4 编写的测试,可以使用 JUnit 5 的 Vintage 引擎来运行它们。
要使用 Vintage 引擎,请添加对
|
hamcrest-core 已被排除,转而使用作为 org.hamcrest:hamcrest 一部分的 spring-boot-starter-test。