Not generating excel report when script run thru Maven | Selenium Forum
M
Posted on 02/03/2016
Hi:

I have implemented the Module 20 Datadriven TestNg Maven framework. When I run the framework by right-clicking on TestNg.xml, the excel reports are generated. But when I run the script by Maven or thru command prompt, no excel report is generated.

My requirement is, is it possible to run the script thru Maven and generate the Excel report?

I am attaching the framework with this post.

Thanks in advance.

M
Replied on 02/03/2016

excel reports? i'm not sure which reports are those.

but if you want reports from maven use this.


1. go to this link <http://relevantcodes.com/testng-listener-using-extentreports/>
2. create class "ExtentReporterNG". This is Listener class and put second block code in it from upper link and save it.
3. put ExtentReporterNG this listener in your testneg.xml. change package name with your package name.
<listeners>
<listener class-name="package.ExtentReporterNG" />
</listeners>
4. Add dependency in you POM.xml
<!-- Extent Reports -->
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.40.1</version>
</dependency>

5. now open cmd prompt and go to your project location and run command "mvn compile" and after it run "mvn package"
6. go in eclipse and refresh your project and run your testng.xml
7. after running refresh your project and check report in test output folder.
8. a folder generate with your class name. check extent.html in it and open this in web browser.


M
Replied on 03/03/2016

Hi Ashish:

The Excel report you generate under source folder under \target\reports which uses the ReportTemplate.xlsx. This gets generated only when right clicking on TestNg.xml and are not generated when running the script thru Maven/command prompt.

Even the Extent reports are not generated by Maven but are generated when running thru TestNg.xml.

Please help.


M
Replied on 03/03/2016

you can use maven sunfire pulgin to run testng.xml by pom.xml


M
Replied on 04/03/2016

I already have that plugin in pom.xml

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>
</configuration>
</plugin>

When I run thru pom.xml, folder by name 'null' is generated with the log files but the excel report is not generated.


M
Replied on 04/03/2016

send a screen shot of sunfire plugin and console output when you are running it.


M
Replied on 06/03/2016

Here is the pom.xml I have

<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.company.datadriven</groupId>
<artifactId>DataDrivenFramework_TestNG</artifactId>
<version>1</version>
<packaging>jar</packaging>

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

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

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.8</version>
<scope>test</scope>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>
<!-- POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.1</version>
</dependency>

<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
<!-- Log4J -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<!-- JavaMail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.04</version>
</dependency>


</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>


</configuration>


</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<!-- TestNG-xslt related configuration. -->
<plugin>
<groupId>org.reportyng</groupId>
<artifactId>reporty-ng</artifactId>
<version>1.2</version>
<configuration>
<!-- Output directory for the testng xslt report -->
<outputdir>/target/testng-xslt-report</outputdir>
<sorttestcaselinks>true</sorttestcaselinks>
<testdetailsfilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testdetailsfilter>
<showruntimetotals>true</showruntimetotals>
</configuration>
</plugin>
</plugins>
</reporting>

<pluginRepositories>
<pluginRepository>
<id>reporty-ng</id>
<url>https://github.com/cosminaru/reporty-ng/raw/master/dist/maven</url>
</pluginRepository>
</pluginRepositories>

</project>

Here is the Console output:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.vivantech.datadriven:DataDrivenFramework_TestNG:jar:1
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-report-plugin is missing. @ line 81, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DataDrivenFramework_TestNG 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ DataDrivenFramework_TestNG ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\workspace\DataDrivenFramework_TestNG\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ DataDrivenFramework_TestNG ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ DataDrivenFramework_TestNG ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ DataDrivenFramework_TestNG ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ DataDrivenFramework_TestNG ---
[INFO] Surefire report directory: C:\workspace\DataDrivenFramework_TestNG\target\surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@5d1ddcf4
C:\TestData\Sample\
Total rows - 26
Test Starts from row Number - 1
Total rows of data are - 3
Total rows - 11
Test Starts from row Number - 1
Total rows of data are - 3
Total rows - 26
Test Starts from row Number - 1
Total rows of data are - 3
C:\TestData\Sample\
Total rows - 26
Test Starts from row Number - 7
Total rows of data are - 3
Total rows - 11
Test Starts from row Number - 7
Total rows of data are - 3
Tests run: 18, Failures: 0, Errors: 0, Skipped: 11, Time elapsed: 3.757 sec

Results :

Tests run: 18, Failures: 0, Errors: 0, Skipped: 11

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.127 s
[INFO] Finished at: 2016-03-06T13:42:22-08:00
[INFO] Final Memory: 12M/224M
[INFO] ------------------------------------------------------------------------


M
Replied on 06/03/2016

replace this



<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>


M
Replied on 07/03/2016

I replaced it but still the Excel report is not generated when running thru pom.xml. I am attaching the pom.xml file.

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DataDrivenFramework_TestNG 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ DataDrivenFramework_TestNG ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\workspace\DataDrivenFramework_TestNG\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ DataDrivenFramework_TestNG ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ DataDrivenFramework_TestNG ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ DataDrivenFramework_TestNG ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ DataDrivenFramework_TestNG ---
[INFO] Surefire report directory: C:\workspace\DataDrivenFramework_TestNG\target\surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@163f47e
C:\TestData\Sample\
Total rows - 26
Test Starts from row Number - 1
Total rows of data are - 3
Total rows - 11
Test Starts from row Number - 1
Total rows of data are - 3
Total rows - 26
Test Starts from row Number - 1
Total rows of data are - 3
C:\TestData\Sample\
Total rows - 26
Test Starts from row Number - 7
Total rows of data are - 3
Total rows - 11
Test Starts from row Number - 7
Total rows of data are - 3
Tests run: 18, Failures: 0, Errors: 0, Skipped: 11, Time elapsed: 3.688 sec

Results :

Tests run: 18, Failures: 0, Errors: 0, Skipped: 11

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.551 s
[INFO] Finished at: 2016-03-07T20:36:03-08:00
[INFO] Final Memory: 11M/219M
[INFO] ------------------------------------------------------------------------


M
Replied on 07/03/2016

extent reports is not being generated?


M
Replied on 08/03/2016

No, the Excel report is not being generated. Under the projectfolder/target/reports. The java jdk version I am using is jdk 1.7.0.79. Is this the correct version?


M
Replied on 08/03/2016

check under all the folder the there should be [color=#FF0000:3t8x0qvt]extent.html[/color:3t8x0qvt] file present.


M
Replied on 13/03/2016

No both the excel report and extent report are not generated when running thru pom.xml.


M
Replied on 13/03/2016

send your project.


M
Replied on 14/03/2016

Attached is the project.


M
Replied on 14/03/2016

you have to add listener for extent reports to work

Responsive image