maven-surefire-report-plugin没有生成surefire-report.html

anz*_*ney 5 maven-2 maven maven-surefire-plugin

我运行时无法获取maven-surefire-report-plugin来生成surefire-report.html:

mvn clean deploy site
mvn clean site
mvn site
mvn clean install site
Run Code Online (Sandbox Code Playgroud)

我能够获得生成报告的唯一一次是我运行时:

mvn surefire-report:report
Run Code Online (Sandbox Code Playgroud)

这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>blah.blah</groupId>
    <artifactId>build</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>build</name>
    <description>build</description>

    <properties>
        ...
    </properties>

    <modules>
        <module>../report</module>
    </modules>

    <dependencyManagement>
        <dependencies>
        ...
            <!-- Custom local repository dependencies -->
            <dependency>
                <groupId>asm</groupId>
                <artifactId>asm-commons</artifactId>
                <version>3.1</version>
            </dependency>
        ...
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                ...
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-Xmx1024m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*_UT.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/*_IT.java</exclude>
                        <exclude>**/*_DIT.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.7.2</version>
            </plugin>
        </plugins>
    </reporting>
</project>
Run Code Online (Sandbox Code Playgroud)

我的项目中有2个测试和TEST - *.surefire-reports中生成xml文件
此外,站点文件夹是使用cssimages文件夹和内容生成的,但没有报告.

小智 7

测试用例运行完成后,可以CMD mvn Surefire-report:report-only 生成测试报告


yor*_*rkw 6

JIRA中报告了类似的问题,解决方案是在你的pom.xml中使用更高版本的maven-site-plugin 3.0-x:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <version>3.3</version>
    </plugin>
    ...
  </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

  • `3.0`版本不再是测试版.您可以指定`<version> 3.0 </ version>` (2认同)