【问题标题】:maven-surefire-report-plugin not generating surefire-report.htmlmaven-surefire-report-plugin 不生成surefire-report.html
【发布时间】:2023-12-01 23:12:01
【问题描述】:

当我运行时,我无法让 ma​​ven-surefire-report-plugin 生成 surefire-report.html

mvn clean deploy site
mvn clean site
mvn site
mvn clean install site

我唯一能够生成报告的时间是在我运行时:

mvn surefire-report:report

这是我的 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>

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

【问题讨论】:

  • 你使用的maven版本是什么?

标签: maven maven-2 maven-surefire-plugin


【解决方案1】:

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>

【讨论】:

  • 3.0 版本不再是测试版。您可以指定&lt;version&gt;3.0&lt;/version&gt;
  • 如果您想使用最新版本的 maven-site-plugin,请查看this。截至今天(2013 年 3 月 12 日),最新版本为 3.2。
【解决方案2】:

测试用例运行完成后,可以通过cmd mvn surefire-report:report-only 生成测试报告

【讨论】:

  • 所以应该包含在工作设置目标中的目标名称是surefire-report:report-only