MVN 故障安全:集成测试



我正在使用maven 2,集成测试在*IT.java文件中。当我运行命令mvn failsafe:integration-test集成测试运行时,运行罚款。但是当我运行mvn integration-test时,它不会运行我的集成测试。如何删除前缀failsafe:

在绒球中.xml我使用:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.12</version>
    <executions>
        <execution>
        <phase>integration-test</phase>
        <goals>
            <goal>integration-test</goal>
            <goal>verify</goal>
        </goals>
        </execution>
    </executions>
</plugin>

更新
我还尝试按照pom.xml设置进行操作,然后mvn clean verify.我只得到了 JUnit 测试的可靠报告。控制台输出上仍然缺少 JUnit 集成测试。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.12</version>
    <executions>
        <execution>
            <id>failsafe-integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
        <execution>
            <id>failsafe-verify</id>
            <phase>verify</phase>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

现在我通过插件设置绑定禁用单元测试:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!-- Disable unit tests -->
        <skip>true</skip>
    </configuration>
</plugin>

文 我运行mvn clean verify我的故障安全集成测试运行!但是为什么它不能与万无一失的单元测试一起使用呢?知道吗?

你有失败的单元测试吗?

当您执行mvn failsafe:integration-test时,您将显式调用故障保护,但是当您执行mvn integration-test时,您将调用该阶段,因此将执行单元测试,并且如果单元测试失败,则永远不会达到集成阶段。这可以解释为什么当您通过配置单元测试的执行跳过时mvn clean verify起作用。

最新更新