maven - junit 和 hamcrest 声明

标签 maven junit hamcrest

我在 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>

最佳答案

如果您浏览到 search.maven.org您可以搜索 Artifact 并查看它们的依赖项。如果您使用带有 Maven 插件的 Eclipse,您还可以在 POM 编辑器中单击 Dependency Hierarchy。

看着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 库。

关于maven - junit 和 hamcrest 声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15660807/

相关文章:

java - Hamcrest 测试一个 map 是否包含另一个 map 中的所有条目

java - 如何使用 Rest assured 验证数组中元素的正确值

java - Maven 构建后缺少类文件

Java Fest 消耗控制台输出

java - 使用 java 8 编写的 DAO 类方法的 Mockito 测试用例

java - 如何在 junit 中测试这个 Web 层?

java - JUnit 抛出 java.lang.NoClassDefFoundError : org/hamcrest/MatcherAssert

maven - 通过maven配置Sonar sonar.issue.ignore.multicriteria

maven - 为什么 Maven 的依赖调解不选择最新版本?

java - 标签taskdef找不到 'org.jvnet.jaxb2_commons.xjc.XJC2Task'类