【发布时间】:2023-04-04 06:50:01
【问题描述】:
跑步
assertThat(collection, allOf(hasItems(i1, i2, i3), hasSize(3)));
从 Eclipse (Run as -> Junit) 一切正常,但是当我执行 Maven 测试 (mvn clean test) 时,它在 test-compile 阶段失败,解释如下
[ERROR] The method allOf(Matcher<? super T>, Matcher<? super T>) in the type AllOf<T> is not applicable for the arguments (Matcher<Iterable<Song>>, Matcher<Collection<? extends Object>>)
依赖关系是
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
我做错了什么?
谢谢
斯特凡诺
【问题讨论】:
标签: unit-testing maven hamcrest