Reporting in TestNG

Why we need Reporting?
When we are using Selenium or any other automation tool (say UFT), we are replicating user interactions on the AUT(Application under Test).But our aim is not only to test AUT, but to comprehend the result of test execution, points of failure(Bug), and reason of the failure, and reporting it to development team or higher management. Thus reporting is the most crucial aspect of our test execution, which helps in keeping an eye on the execution flow or for debugging in case of failures.
Read more on Reporting in UFT

TestNG Reporting:- 
We have already seen the default reporting in TestNG using index.html and emailable-report.html.Further to this we can add our own user friendly logs in the HMTL reporting by using Reporter class. We can also create costume reporting in TestNG using ReportNG


Reporter.log in TestNG
Reporter.Log as an overloaded method

Reporter.Log(“Message”, logToStandardOut)

Message:-String message for output
logToStandardOut:- is a Boolean value, which signifies whether to print the “Message” on console too. Incase it is set “False”, message won’t be shown in console output of Eclipse.


import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Reporter;
import org.testng.annotations.Test;

public class ReporterInTestNG {

public void maximize(){
WebDriver driver = new FirefoxDriver();
//Variable to disable/Enable Reporter results in Console
boolean bolConsole;
Reporter.log("Driver Object Created!",bolConsole);
Reporter.log("URL is Launched!",bolConsole);
//Using "Maximize" command
Reporter.log("Maximized browser using 'Maximize' command!",bolConsole);
//Resize window
driver.manage().window().setSize(new Dimension(200, 100));
Reporter.log("Rezized window using setSize!",bolConsole);
//Quit Browser



Console(bolconsole = true)

Console output in TestNg
Console output in TestNg

 index.html, (inside test-output folder)

HTML Results in TestNG
HTML Results in TestNG

Note:- Incase we are setting (bolconsole=false) in our code, console will not display the “Reporter” messages.

Key points:-
We can implement our own costume reporting in TestNG by implementing:-

How to open HTML reports in TestNG

Leave a Reply

Your email address will not be published. Required fields are marked *