【问题标题】:maven-surefire-report-plugin not generating report.html when build is failed构建失败时,maven-surefire-report-plugin 不生成report.html
【发布时间】:2019-01-14 07:21:03
【问题描述】:

maven-surefire-report-plugin 无法生成 HTML 报告,当命令像

mvn clean package site
mvn site
mvn clean deploy site

无法生成成功的构建,它会生成成功构建的 HTML 报告。

当使用 mvn site 命令时,会出现以下错误

[WARNING] Error injecting: org.apache.maven.report.projectinfo.CiManagementRepor                                                                                                                                                                                              t
java.lang.NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentCont                                                                                                                                                                                               ent

无论构建失败与否,生成 HTML 报告的唯一时间是在我运行时

mvn surefire-report:report

这是我的主 POM.xml

<build>
       <plugins>
          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                </configuration>
          </plugin>
          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.7.1</version>
          </plugin>
</build>
        </plugins>
<reporting>
        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <showSuccess>true</showSuccess>
                <outputName>Reports</outputName>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.7.1</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
            <version>2.5</version>
        </plugin>
    </plugins>
    </reporting>

连站点文件夹都没有生成

【问题讨论】:

  • 你在使用--fail-at-end吗?和-Dmaven.test.failure.ignore=true?
  • 您能否详细说明您的评论,因为我是新手
  • 只需拨打mvn clean deploy --fail-at-end -Dmaven.test.failure.ignore=true...
  • 它确实在 xml 中生成报告,但不在 HTML(站点文件夹)中生成报告

标签: java maven maven-surefire-plugin


【解决方案1】:

如果无论单元测试的结果如何,您都希望您的 maven 构建成功,而不是像 @khmarbaise 建议的那样做是正确的:

mvn clean package -Dmaven.test.failure.ignore=true

如果您希望您的测试在构建失败但之后仍然生成报告,那么以下对我有用:

mvn clean test failsafe:integration-test
mvn -Dmaven.test.skip=true surefire-report:report

(来源:https://stackoverflow.com/a/4113187/9478795

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 2014-02-21
    • 2013-08-28
    • 2010-11-26
    • 1970-01-01
    • 2020-11-09
    相关资源
    最近更新 更多