nolexa
nolexa

Reputation: 2492

Disable HTML reporting for TestNG with Maven

We run TestNG tests with Maven 3.0.5, Surefire 2.7.1, and TestNG 5.10.

We want to disable generation of HTML reports that are create under target/surefire-reports/Command line suite, the latter directory being a TestNG suite name. We believe that it's TestNG's reporter that creates a report, but despite the following configuration, the reporting cannot be disabled.

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.7.1</version>
    <configuration>
        <properties>
            <property>
                <name>usedefaultlisteners</name>
                <value>false</value>
            </property>
        </properties>
    </configuration>
</plugin>

Is there a way to switch off the HTML reporting? It takes a painful amount of time on each test run.

Upvotes: 2

Views: 2416

Answers (1)

Tunaki
Tunaki

Reputation: 137084

There is a bug with those versions of TestNG and Surefire, making configuring with the listeners not working. From Using Custom Listeners and Reporters in the Surefire documentation:

Unsupported versions: - TestNG 5.14.1 and 5.14.2: Due to an internal TestNG issue, listeners and reporters are not working with TestNG. Please upgrade TestNG to version 5.14.9 or higher. Note: It may be fixed in a future surefire version.

This probably affect 5.10 as well, so you need to upgrade to a newer version of TestNG. While at it, you can also upgrade Maven Surefire Plugin to the current latest, which is 2.19.1:

<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.9.8</version> <!-- or 5.14.10 for the latest in 5.x branch -->
  <scope>test</scope>
</dependency>

with

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.19.1</version>
  <configuration>
    <properties>
      <property>
        <name>usedefaultlisteners</name>
        <value>false</value>
      </property>
    </properties>
  </configuration>
</plugin>

Is it worth adding that this will disable the HTML reports from being generated by TestNG, but Surefire itself will still generate an XML report. You can disable that one with the disableXmlReport parameter in the Surefire configuration.

Upvotes: 4

Related Questions