maven - 带有一个参数库的 AssertThat
问题描述
我试图从http://mapstruct.org/#get-started执行测试
他们在那里使用代码
assertThat( carDto ).isNotNull();
由于在许多教程中他们没有为可读性添加 import 子句,而且我不是测试工具的大师,我添加了最新的 junit mvn 依赖项。
<junit.version>4.12</junit.version>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
在 Java 中,我添加了导入:
import static org.junit.Assert.assertThat;
Eclipse 抱怨 assertThat 只有一种选择,即
类型 Assert 中的 assertThat(T, Matcher) 不适用于参数 (CarDto)
难道我做错了什么?这是来自我不知道的不同库的方法吗?我在互联网上搜索并找到了一些东西,但我不确定它是否被广泛采用,我想记住这一点,因为我们将在实际项目中使用它。
PS:也试过org.hamcrest.MatcherAssert.assertThat;但它会产生相同的错误,它们的库的签名是相同的。
解决方案
assertThat( carDto ).isNotNull();
看起来像 AssertJ,它没有随 JUnit 一起分发。看看这个快速入门。
推荐阅读
- azure - 如何更改管道变量以在 Azure DevOps 的下一个构建中使用
- python - 我想将 res.partner 地址中的实际城市字段更改为 many2one 字段而不添加新字段
- pine-script - 图表上的计算值
- arrays - Flutter:在包含 Listview 的 Futurebuilder 中显示来自 JSON 的字符串数组
- python - 无法将关键字“id”解析为字段。选项有:完成、task_priority、text、user、user_id
- python-3.x - 从给定列表中,删除所有偶数(包括 0)并打印出结果列表
- jakarta-ee - 如何修复 DeploymentException:处理归档中的 glassfish-resources.xml(s) 时失败
- python - 更改导入包后修复导入的更好方法
- excel - 隐藏行的动态范围
- react-native - 如何在具有固定高度的水平 FlatList 上处理 Drag'n Drop 手势