use*_*643 8 junit hamcrest maven
我在4.10使用junit并在1.3处声明了hamcrest-core,在1.3处声明了hamcrest-library.我的问题是在junit 4.10中嵌入的hamcrest-library和hamcrest-core.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>
Run Code Online (Sandbox Code Playgroud)
如果您浏览到search.maven.org,则可以搜索工件并查看其依赖项.如果您使用带有Maven插件的Eclipse,则还可以在POM编辑器中单击Dependency Hierarchy.
在Maven网站上看,您可以看到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>
Run Code Online (Sandbox Code Playgroud)
Hamcrest库你必须自己添加.
JUnit 4.10和JUnit 4.11(如下所示):
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
...分别使用hamcrest-core 1.1和1.3.你可以通过利用依赖插件的树目标(运行mvn依赖:树)来自己看到这个:
$ 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] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
听起来很愚蠢,你需要包含适当的hamcrest-library artefact来利用Hamcrest Matchers.希望这有助于......
| 归档时间: |
|
| 查看次数: |
16272 次 |
| 最近记录: |