Saturday, 4 June 2016

How to Generate XSLT reports by using Ant+TestNG



We have to follow below steps to generate XSLT reports

1) ANT Installation
2) Configure XSLT and build.xml
3) Genrate XSLT report by using ANT

1) ANT Installation

-> Download Latest Version of apache-ant zip
Download latest version of apache-ant from

http://ant.apache.org/bindownload.cgi.

Extract zip folder and save into our local path.

-> Set JAVA_HOME Environment variables

* Right click on My Computer -> Properties and go to -> Advanced tab.
* Clicking on Environment variables button will open Environment variable dialog.
* Click on New button from System Variables box and add Variable Name = JAVA_HOME and Variable Value = Path of your jdk folder.
* Here my JDK folder path is 'C:\Program Files\Java\jdk1.8.0'

-> Set ANT_HOME Environment Variables

* Right click on My Computer -> Properties and go to -> Advanced tab.
* Clicking on Environment variables button will open Environment variable dialog.
* Click on New button from System Variables box and add Variable Name = ANT_HOME and Variable Value = Path of your jdk folder.
* Here my ANT folder path is 'D:\Selenium\apache-ant-1.9.7'

-> Edit Path Variable

* Right click on My Computer -> Properties and go to -> Advanced tab.
* Clicking on Environment variables button will open Environment variable dialog.
* Edit existing Path variable by selecting Path variable from System variables list.
* And click Edit button and insert  %JAVA_HOME%\bin;%ANT_HOME%\bin  at the end of Path variable value string.
* Do not forget to put semicolon (;) before %JAVA_HOME%\bin

-> Copy tools.jar from jdk/lib and paste It In jre/lib
* There will be 2 folders In your C:Program Files\Java folder.
* In my system It Is jdk1.8.0 and jre8.
* Open C:\Program Files\Java\jdk1.8.0\lib folder and copy tools.jar file.
* Open C:\Program Files\Java\jre8\lib and paste tools.jar In to It.

Now restart your system to getting system variables changes effect.

Verify ant configured properly or not
To verify that ant Is configured properly or not, follow the bellow given steps after restarting system
* Open command prompt.
* Type command "ant" and press Enter button.
* It should show you message as bellow.


C:\Users\user>ant
Buildfile: build.xml does not exist!
Build failed





2) Configure XSLT and build.xml


-> The below jar files shoule be under lib folder

* saxon-8.7
* SaxonLiaison
* testng-xslt-maven-plugin-test-0.0
* Selenium-server-standalone 2.47

-> The below files should be under project path

* build.xml  -> Link to download
* testng-results.xsl -> Link to Download

-> Configure build.xml file

Verify the Value for "project.jars" property at line no 10 of build.xml file. It should be the path of "lib" folder of project.
Verify the path of testng-results.xsl file at line no 91 of build.xml file. It should be  path of testng-results.xsl.

Note : Don't change any thing else In build.xml file.




3) Genrate XSLT report by using ANT


Once your test execution get completed and testng results generated, We can go to generate XSLT report. You need to follow bellow given steps to generate XSLT report.


-> Open command prompt.

-> Goto your project

E:\Selenium_Project\Selenium_Testing>

-> Type "ant" to check we are in correct path to generate XSLT report.


E:\Selenium_Project\Selenium_Testing>ant
Buildfile: E:\Selenium_Project\Selenium_Testing\build.xml

usage:
     [echo]
     [echo]             ant run will execute the test
     [echo]

BUILD SUCCESSFUL
Total time: 0 seconds


-> Remove Previous Build : Type Command = "ant clear"

 It should give message "BUILD SUCCESSFUL"


E:\Selenium_Project\Selenium_Testing>ant clear
Buildfile: E:\Selenium_Project\Selenium_Testing\build.xml

clear:
   [delete] Deleting directory E:\Selenium_Project\Selenium_Testing\build

BUILD SUCCESSFUL
Total time: 0 seconds


-> Compile And Generate New Build Folder : Type Command = "ant compile".

 It should give message "BUILD SUCCESSFUL"

E:\Selenium_Project\Selenium_Testing>ant compile


-> Verify Build Folder Is Generated : Now Refresh your project In eclipse.
 ant compile command will created new folder with name of  build under your project

-> Execute Test Suites : Type Command = ant run In command prompt and press enter.
It will execute your all software automation test suites which are included In testng.xml file.

 So now you can execute your software test suites from command prompt Instead of testng.xml file.

-> Generate XSLT Reports : Type Command = ant reports In command prompt and press enter.
It should give message "BUILD SUCCESSFUL"

-> open XSLT Report : Once more refresh your project In eclipse.

 ant reports command will create new folder with name = XSLT_Reports under your project


->You will find index.html file In XSLT_Reports folder.
That Is XSLT Report of your webdriver test. Open that file In any web browser.
 It Is Interactive and easy to understand that how many test cases are Pass, Fail and Skip for specific test case.



Note : If pie chart is not available in your report then you will get error message in browser like below


Error Message : SVG Pie Charts are not available. Please install a SVG viewer for your browser


So please install SVG viewer in order to see pie chart in XSLT reports.

2 comments:

  1. Vielen Dank, dass Sie komplexe Konzepte in leicht verdauliche Teile zerlegt haben. Ich weiß es zu schätzen, dass der Klick test objektiv ist, da ich in einer datengesteuerten Branche arbeite. Ein Selbstbewertungstool, das klare Ergebnisse liefert und leicht zu interpretieren ist, kann wertvoll sein.

    ReplyDelete
  2. Your positivity and enthusiasm are contagious, thank you for brightening our days!The sense of adventure and exploration our minecraft servers offers is unparalleled, with endless opportunities to discover new wonders.

    ReplyDelete