In this post, we will see how to convert testng report (index.html) to a more readable/emailable report by using ANT build and build.xml.
We will see how we can generate the following report[screenshot] after done the required steps:
testcase2: pass
testcase3: failed
testcase4: skipped
testng.xml -
Right click on the project, select "TestNG" and click on "Convert to TestNG" to create the testng.xml and place under project folder.
How to Run the build.xml:
1) After all the above setup is done, Right click on the build.xml and select "Run As", click on "Ant Build...", a dialog appears to select and execute the required targets.
2) Even we can run the build.xml from the command prompt:
Customized html report page - open from folder /XSLT_Reports/output/index.html to see the report as shown in the beginning.
We will see how we can generate the following report[screenshot] after done the required steps:
Things Required:
Eclipse IDE -
If you are new, please follow this link
Create 4 .java files such a way that: 2 successful, 1 skipped and 1 failed on run
testcase1: pass
If you are new, please follow this link
Create 4 .java files such a way that: 2 successful, 1 skipped and 1 failed on run
testcase1: pass
1 2 3 4 5 6 7 | package tcs; import org.testng.annotations.Test; public class tc1 { @Test public void method1(){ System.out.println("tc1: testcase1");} } |
1 2 3 4 5 6 7 | package tcs; import org.testng.annotations.Test; public class tc2 { @Test public void method1(){ System.out.println("tc2: testcase2");} } |
1 2 3 4 5 6 7 8 9 | package tcs; import org.testng.annotations.Test; public class tc3 { @Test public void method1(){ int i = 5/0; System.out.println(i+"testcase3"); } } |
1 2 3 4 5 6 7 8 | package tcs; import org.testng.SkipException; import org.testng.annotations.Test; public class tc4 { @Test public void method1(){ throw new SkipException("skipped: testcase4");} } |
testng.xml -
Right click on the project, select "TestNG" and click on "Convert to TestNG" to create the testng.xml and place under project folder.
ANT build -
Download the latest zip file from here,
Extract and keep it in a easily accessible folder and follow below steps:
Environmental setup for ANT:
Add / Edit System variables "path" as: append the "apache ANT" extracted folder path as value.
path = C:\apache-ant-1.9.4\bin (consider the extracted file is on C:\ drive)
Add / Edit System variables "path" as: append the "apache ANT" extracted folder path as value.
path = C:\apache-ant-1.9.4\bin (consider the extracted file is on C:\ drive)
To know how to update environmental variable, click here.
build.xml and testng-results.xsl:
Download from here and place under your project folder.
build.xml and testng-results.xsl:
Download from here and place under your project folder.
How to Run the build.xml:
1) After all the above setup is done, Right click on the build.xml and select "Run As", click on "Ant Build...", a dialog appears to select and execute the required targets.
2) Even we can run the build.xml from the command prompt:
On the current directory (location, where your project resides), Hold "Shift key" and Right click on the directory and select option "Open command window here" and type the following command to execute build.xml or tests
let's say my project is under c:\
c:\myproject > ant -buildfile build.xml and press Enter (this will execute the default target)
To execute particular target (let's say I have a target "GenerateReport"
c:\myproject > ant -buildfile build.xml GenerateReport and click on Enter
Customized html report page - open from folder /XSLT_Reports/output/index.html to see the report as shown in the beginning.
Testing is the only way to deliver reliable products in the Information Technology market. Articles like this are vital in improvising one's ability as a software testing professional. Thank you so much for sharing this information in here. Keep blogging.
ReplyDeleteSoftware testing training in chennai | Software testing training | Software testing training chennai | Software testing course chennai
Automation will make any work to be completed so soon(Selenium training in chennai), in addition to this recording the actions is possible with automated tool. Your content explicitely states the same(Selenium testing training). Thanks for sharing this worth able content in here. This was very useful to me as well. Keep blogging like this.
ReplyDeleteGSSSB 2480 Revenue Talati Bharti Recruitment 2016
ReplyDeleteVery well written information. It will be beneficial to anyone who utilizes it, Keep up the good work.
Assam 2564 Police Constable Recruitment 2016 Apply Online
ReplyDeleteI go to see everyday a few web pages and information sites to read posts, however this blog gives quality based articles...........
Hi, I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog. Selenium Training in Chennai
ReplyDeleteTechnology place a vital part in humans ecosystem. So in order to survive one must be up to date. Thanks for sharing this information in here. Keep blogging article like this. I have bookmarked this page for future reference.
ReplyDeleteHadoop Training Chennai | Hadoop Training in Chennai | JAVA training in Chennai
Hi, This is really nice blog. You have done really great job. Keep posting.
ReplyDeleteRegards..
QTP Training in Chennai
Awesome article to nice sharing Training and certification on courses helps you to study this technology in featurebest selenium training in chennai
ReplyDelete
ReplyDeleteI am happy to found such helpful and fascinating post that is written in well manner.
QTP Training in Chennai | Software Testing Training in Chennai | Selenium Training in Chennai
Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
ReplyDeleteSoftware Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery
I am happy for sharing on this blog its awesome blog I really impressed.
ReplyDeleteBig Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery