ReportNG Installation

1,130 views
Skip to first unread message

Deepa

unread,
Mar 7, 2011, 6:51:59 AM3/7/11
to Selenium Users
Hi All,
I have installed TestNG, Prepared a sample script on google search,
and run it. Then, It could generate the TestNG reports.
I now want to generate reports using ReportNG. For that, I have
downloaded ReportNG, and have added its jars in the project classpath.
What is the next step to generate ReportNG reports. I am using
eclipse.

Any one, please share me ur experiences, It would be greatly
appreciated


Thanks & Regards
Deepa Kiran

naveed

unread,
Mar 7, 2011, 12:42:55 PM3/7/11
to Selenium Users
Deepa,

Do following steps

1. Download ReportNG (jar) files (there should be two jar file like a.
testng.jar b. velocity.jar)
2. Include ReportNG jars into your project
3. Download Ant and set your PATH up to the bin folder of ant
directory by following below

a. Download the binary distribution.
b. Unpack the binary distribution in the directory of your choice.
c. Add <where you unpacked the zip file>/apache-ant-1.7.0/bin to
your PATH environment variable.
d. Check that your Ant installation is OK:

$ ant -version
Apache Ant version 1.7.0 compiled on December 13 2006

3. Copy the below code (save it as build.xml) file into root directory
of your project, and change the path of all jar file in the section
showing comments like "<!-- You need the put paths of your own ---->"
based on your project directory structure.
4. Now from Project Explorer window in Eclipse, right click on
Build.xml file and run as 'Ant Build'
5. It should work fine

let me know if still facing some issue.


======================Build.xml===============================
<project name="Projectname" default="run" basedir=".">
<property name="classes.dir" value="${basedir}\bin" />
<property name="src.dir" value="${basedir}\src" />
<property name="report.dir" value="${basedir}\reports" />
<property name="browser" value="C:/Program Files/Mozilla Firefox/
firefox.exe"/>


<!-- You need the put paths of your own ---->
<path id="libs">
<pathelement path="${basedir}\libs\testng-5.9-jdk15.jar"/>
<pathelement path="${basedir}\libs\selenium-java-client-driver.jar"/
>
<pathelement path="${basedir}\libs\selenium-server.jar"/>
<pathelement path="${basedir}\libs\reportng-1.0.jar"/>
<pathelement path="${basedir}\libs\velocity-dep-1.4.jar"/>
<pathelement path="${basedir}\${classes.dir}"/>
</path>

<!-- Start the server -->
<target name="startServer">
<echo>Starting Selenium Server...</echo>
<java jar="${basedir}\libs\selenium-server.jar" fork="true"
spawn="true">
<arg line="-multiwindow -log c:\log.txt"/>
</java>

</target>

<!-- Delete old data and create new directories -->
<target name="init" depends="startServer">

<echo>Initlizing...</echo>

<delete dir="${classes.dir}" />
<mkdir dir="${classes.dir}"/>

<delete dir="${report.dir}" />
<mkdir dir="${report.dir}"/>

</target>

<!-- Complies the java files -->
<echo>Compling...</echo>
<target name="compile" depends="init">
<echo>Compiling...</echo>
<javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}"
classpathref="libs" />

</target>

<!-- Runs the file and generates Reportng report -->
<target name="run" description="Running test" depends="compile">
<echo>Running...</echo>
<taskdef resource="testngtasks" classpathref="libs"/>
<testng outputDir="${report.dir}"
haltonfailure="true"
useDefaultListeners="false"
listeners="org.uncommons.reportng.HTMLReporter"
classpathref="libs">
<classfileset dir="${classes.dir}" includes="**/*.class" />

</testng>
<!-- Open the report in browser.-->
<exec executable="${browser}" spawn="yes">
<arg line="'${report.dir}\html\index.html'" />
</exec>
</target>

</project>

=======================Code End================================

Good luck,

micsky

unread,
Mar 7, 2011, 12:50:48 PM3/7/11
to Selenium Users
If you start TestNG programmatically (like me) you can do this:

/*
* Create a TestNG object
*/
TestNG testngCore = new TestNG();
/*
* Disable default Reports.
*/
testngCore.setUseDefaultListeners(false);
/*
* Set Listener: Detailed Report (ReportNG)
*/
testngCore.addListener(new HTMLReporter());
/*
* ReportNG: Set system property to turn off output escaping
* Turns off escaping output logs.
*/
System.setProperty("org.uncommons.reportng.escape-output",
"false");
/*
* ReportNG: Set title
*/
System.setProperty("org.uncommons.reportng.title", "Some
Title");
/*
* Set the report output directory
* Note: I can't remember but I may have customized ReportNG
to add this functionally
*/
testngCore.setOutputDirectory("path/to/output/directory");

If you don't start programmatically you can accomplish all the same by
putting these settings in the TestNG.xml

Cheers,
-Mike

Deepa Kiran Bagepalli

unread,
Mar 8, 2011, 1:24:09 AM3/8/11
to seleniu...@googlegroups.com, naveed
my lot lot Thanks for all... for helping me
I have implemented the ant method and could successfully generate the reports

Thanks once again
Deepa

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Scal

unread,
Mar 18, 2011, 12:11:21 PM3/18/11
to Selenium Users
Hi Mike;
I was interested and started to test this but I am not sure about the
HTMLReporter object, can you let us know from which package it comes
from?

Thanks;
Reply all
Reply to author
Forward
0 new messages