【问题标题】:configure junit with maven project使用 maven 项目配置 junit
【发布时间】:2019-02-07 06:19:23
【问题描述】:

我有一个 maven 项目,它有以下 pom

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.7</version>
            <type>jar</type>
        </dependency>


    </dependencies>

以及下面提到的maven-compiler-plugin:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

每当我构建我的项目时,由于 maven-compiler-plugin ,Junit 4.12 版本会被安装。

问题

我不想配置 Junit 4.12,因为测试与 Junit 4.12 并行运行,这是我不想要的。

【问题讨论】:

  • 单元测试应该相互隔离,这意味着并行运行不会造成任何伤害。如果您的单元测试不满足此条件,您应该重新考虑您的设计,而不是寻找解决方法...

标签: maven junit


【解决方案1】:

我无法重现您的情况。 maven-compiler-plugin 在依赖项中没有 junit。因为它,你不可能得到 Junit 4.12。

运行mvn dependency:tree 看看你从哪里得到它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 2016-04-29
    • 2017-04-11
    • 1970-01-01
    相关资源
    最近更新 更多