maven-failsafe-plugin 失败和构建成功?

标签 maven maven-plugin maven-failsafe-plugin

我想使用 maven-failsafe-plugin 来运行一些集成测试。如果任何测试失败,我希望 Maven 使构建失败而不是 BUILD SUCCESS。

Tests run: 103, Failures: 1, Errors: 0, Skipped: 26
[INFO] BUILD SUCCESS*

我该如何配置它,构建不成功是什么?

我的故障保护插件配置为:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${failsafe.version}</version>
    <configuration>
        <systemProperties>
            <CI_INTEGRATION_OVERRIDE_PATH>${basedir}/..</CI_INTEGRATION_OVERRIDE_PATH>
        </systemProperties>
        <includes>
            <include>**/integration/**/*.java</include>
        </includes>
        <excludes>
            <exclude>**/integration/**/*TestSuite.java</exclude>
        </excludes>
    </configuration>
    <executions>
        <execution>
            <id>integration-test</id>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

最佳答案

正如 Andrew 指出的那样,正确的解决方案是按预期使用故障保护。集成测试目标专门设计为不会使构建失败。如果您想使构建失败,请调用 mvn verifymvn failsafe:verify
对于verify目标工作,它需要读取默认写入${project.build.directory}/failsafe-reports/failsafe-summary.xml的集成测试结果所以请确保它正在生成。

此外,您必须确保绑定(bind)您的 maven-failsafe-plugin配置到 integration-test目标和 verify executions 中的目标部分。

未能添加其中任何一个都将导致 maven 成功构建,而不是在集成测试失败时失败。

关于maven-failsafe-plugin 失败和构建成功?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12279160/

相关文章:

java - 无法使用 IntelliJ 生成可行的 .jar

java - 我看不到Gradle/Maven的意义

maven - Maven Surefire 和 Maven Failsafe 插件有什么区别?

java - 当我从命令行设置参数(例如 -DrunIT=true)时,从配置文件的 Maven 故障安全插件运行集成测试

maven - 运行 mvn clean install 时不要运行集成测试

java - 使用相同描述符 Maven 程序集插件自定义不同格式的文件夹名称

java - 我无法使用 apache-maven3.2.2 构建项目

maven:如何以独立于操作系统的方式加载tools.jar/classes.jar?

java - Spring Boot应用程序失败-错误java包不存在

maven - Maven 源插件 jar 和 jar-no-fork 目标之间的区别?