1

I have an extent report listener and am invoking it from testng.xml and it works perfectly fine. When I invoke the listener from my pom.xml it does not work fine.

There are two questions I have here:

  1. Can I invoke the listener from the testNG.xml without adding the listener to the pom file?
  2. How to get the same output from the testNG.xml and the pom.xml?

If need be I can attach my project as well here. Can some one please suggest what may have gone wrong here.

My testng.xml file is like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<suite name="Suite" verbose="2" parallel="tests" thread-count="2">
<listeners>
       <listener class-name="ExtentReporterNG.ExtentTestNGIReporterListener"/>
   </listeners>

 <test name="Regression1">
    <classes>
             <class name="org.Sample1.AppTest"/>
             <class name="org.Sample2.AppTest"/>
    </classes>
  </test>
 </suite>

My pom.xml is like this:

<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.test.sample</groupId>
  <artifactId>SampleProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <name>SampleProject</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>   
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.10</version>
            <scope>test</scope>
        </dependency>
          <dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>3.0.7</version>
</dependency>
<dependency>
    <groupId>sample</groupId>
    <artifactId>com.sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>C:\\Users\\pchand\\Desktop\\ExtentReport-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
  </dependencies>
  <modules>
    <module>Sample1</module>
    <module>Sample2</module>
  </modules>
    <build>  
    <pluginManagement>
     <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>

     <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.19.1</version>
           <configuration>
              <testFailureIgnore>true</testFailureIgnore>
             <suiteXmlFiles>
                         <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
           <properties>
    <!--         <property>
              <name>usedefaultlisteners</name>
              <value>false</value> disabling default listeners is optional
            </property> -->
            <property>
              <name>listener</name>
              <value>ExtentReporterNG.ExtentTestNGIReporterListener</value>
            </property>
          </properties>
    </configuration>
    </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
SiKing
  • 10,003
  • 10
  • 39
  • 90
user3627332
  • 177
  • 1
  • 3
  • 13

1 Answers1

0
  1. If you use IDE (such as IntelliJ), you can use the testNG plugin to execute test suite xml without using the pom file. You just need to uncheck the default listener option and add your own customized listener in the edit configuration window. testNG configuration

  2. You would have to execute mvn clean test in the terminal to build with pom.xml file