How to disable HTML Reporting for TestNG with Maven?


Maven is a project management and comprehension tool that provides a complete build lifecycle framework. User can automate the project's build infrastructure in almost no time as Maven uses a standard directory layout and a default build lifecycle.

In case of multiple environments, Maven can set−up the way to work as per standards in a very short time. As most of the project setups are simple and reusable, Maven makes life easy while creating reports, checks, build and testing automation setups.

Maven provides developers ways to manage the following:

  • Builds

  • Documentation

  • Reporting

  • Dependencies

  • SCMs

  • Releases

  • Distribution

  • Mailing list

TestNG is a testing framework and can use Maven as build tool. It helps to maintain dependencies and their version at one place in pom.xml. TestNG also generates the different kind of reports like HTML, XML in test−output folder along with maven reports those are present under target/maven−surefire−reports.

Since Maven is a build tool and get more details in the reports it is not worth to generate 2 different HTML reports for same test case run. User can disable HTML reporting of TestNG by simply configure in pom.xml as shown below:

<property>
	<name>usedefaultlisteners</name>
	<value>false</value>
</property>

pom.xml

This is a maven configuration file that is used to organize dependencies, plugins and run the TestNG test cases.

It is very handy when limited tests are needed to execute rather than full suite.

<?xml version="1.0" encoding="UTF-8"?>
<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>com.sample</groupId>
    <artifactId>TestNGProjectct</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
          <configuration>
                  <properties>
                    <property>
                       <name>usedefaultlisteners</name>
                       <value>false</value>
                    </property>
                 </properties>
               </configuration>            
            </plugin>
        </plugins>
    </build>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>          
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.3.0</version>
        </dependency>
    </dependencies>
</project>

Updated on: 16-Aug-2023

90 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements