在 Spring Boot 生产代码中使用 AssertJ

Con*_*Lee 1 unit-testing spring-boot assertj

是否可以在 Spring Boot 生产代码中使用 AssertJ ?我设法在单元测试中使用它,但是'import static org.assertj.core.api.Assertions.*;' 无法在 src/main/java 文件夹的 java 文件中解析,即使我尝试通过更改构建路径并更改 junit.conf 来修复它。或者在生产代码中使用 AssertJ 是一种不好的做法?

Ste*_*dio 7

AssertJ 不适用于生产代码。如果使用 Spring Boot 应用程序进行输入验证,Assert来自 Spring Framework、ValidateApache Commons Lang 或PreconditionsGoogle Guava 可能是不错的选择。