TestNG HTML Report:

 

Why do we need reporting?

  • Aim of automation is not to use the application under test only we test the application as an automation tester, find bugs / issues and report it to development team or higher management team.
  • Reporting software bugs and test case results here is important for testing process.

 

TestNG Reporting:

  • After execution of Selenium script, TestNG will generate a “test-output” folder in the root of the project with list of html files.

 

Two types of reports generated using TestNG:

  1. Index.html:  This is the full report of the currentlly executed script, which includes error, group, time, reporter logs, XPL XML files with details.
  2. emailable-report.html:  This is a brief report of currentlly executed script, highlighting the green test case messages (for pass exam cases) and red (for cases of failed testing).

 

Example: Three methods namely pass, fail and skip with @Test annotation to create TestNG html report.

  • In this example we handle Pass / Fail / Skip test methods.
  • Using Assert we can verify existing test pass or fail.

 

Example: Add Package name and class name in the TestNG.xml file.

  • We call class in TestNG.xml file using package name . (dot) class name E.g: package_name.HTML_Report

  • Right click on TestNG.xml file then Run As TestNG Suite then shows the output in the console panel.

Output: