我在4.10使用junit,1.3使用hamcrest-core,1.3使用hamcrest-库.我的问题是嵌入在junit 4.10中的hamcrest库和hamcrest核。那junit 4.11呢?
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>发布于 2013-03-27 14:14:00
如果浏览到search.maven.org,就可以搜索工件并查看它们的依赖关系。如果您使用的是Eclipse wit插件,您还可以在POM编辑器中单击依赖层次结构。
查看Maven website,您可以看到JUnit 4.11依赖于Hamcrest 1.3:
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
</dependencies>Hamcrest库您必须添加自己。
发布于 2013-03-29 18:21:59
JUnit 4.10和JUnit 4.11 (如下所示):
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>..。船型分别为虎骨核心1.1和1.3。通过利用依赖插件的树目标(运行mvn依赖项: tree ),您可以看到这一点:
$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building testng 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ testng ---
[INFO] testng:testng:jar:1.0-SNAPSHOT
[INFO] \- junit:junit:jar:4.10:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.483s
[INFO] Finished at: Fri Mar 29 12:07:22 MDT 2013
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------虽然这听起来很傻,但您需要包含适当的Hamcrest库艺术品来利用Hamcrest Matcher。希望这能帮上忙..。
https://stackoverflow.com/questions/15660807
复制相似问题