TestNG HTML Report:

Why do we need reporting?

  • The 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 the development team or higher management team.
  • Reporting software bugs and test case results here is important for the testing process.

TestNG Reporting:

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

Two types of reports generated using TestNG:

  1. Index.html:  This is the full report of the currently executed script, which includes error, group, time, reporter logs, XPL XML files with details.
  2. emailable-report.html:  This is a brief report of a currently 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 a @Test annotation to create a TestNG HTML report.

  • In this example, we handle the 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 the 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:

TestNG Report Generation in Selenium WebDriver and How To Generate TestNG Reports and Configuring ReportNG with TestNG for HTML Reports