当构建失败时,maven-surefire-report-plugin不生成report.html

时间:2018-08-07 08:57:34

标签: java maven maven-surefire-plugin

当像这样的命令时,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>

即使未生成站点文件夹

1 个答案:

答案 0 :(得分:0)

如果无论单元测试的结果如何,您都希望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

相关问题