|
此版本仍在开发中,尚未被视为稳定版本。如需最新稳定版本,请使用 Spring Boot 4.0.4! |
测试
Spring Boot 提供了许多实用工具和注解,以帮助测试您的应用程序。
测试支持由两个通用模块提供 – spring-boot-test 包含核心项,spring-boot-test-autoconfigure 支持测试的自动配置 – 以及几个针对特定功能的 -test 模块。
大多数开发人员使用 spring-boot-starter-test Starters,它导入了通用的 Spring Boot 测试模块以及 JUnit Jupiter、AssertJ、Hamcrest 和其他许多有用的库,以及适用于他们特定应用程序的聚焦型 -test 模块。
|
如果您有使用 JUnit 4 的测试,JUnit 6 的 vintage 引擎可用于运行它们。
要使用 vintage 引擎,请添加对
|
hamcrest-core 被排除,而 org.hamcrest:hamcrest 被采用,因为它是 spring-boot-starter-test 的一部分。