2
votes

maven-surefire-report-plugin cannot generate HTML reports ,when commands like

mvn clean package site
mvn site
mvn clean deploy site

aren't able to generate successfull build and it does generate HTML reports on successfull build.

When mvn site command is used it gives following error

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

The only time HTML reports are generated whether the build is failed or not is when i run

mvn surefire-report:report

This is my master 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>

even the site folder is not generated

1
Are you using --fail-at-end? and -Dmaven.test.failure.ignore=true?khmarbaise
Can you please elaborate your comment because i am new to thisakaushik
Simply call mvn clean deploy --fail-at-end -Dmaven.test.failure.ignore=true...khmarbaise
it does generate report in xml but not in HTML(site folder)akaushik

1 Answers

0
votes

If you want your maven build to succeed no matter the result of the unit tests than doing like @khmarbaise suggested it is correct:

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

If you want your tests to fail the build but still generate a report afterwards the following did the trick for me:

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

(Source: https://stackoverflow.com/a/4113187/9478795)