As we know, TestNG provides default html reports with basic information like No. of tests passed, failed, skipped and time taken to execute these tests in milliseconds. But you may not find it very helpful as the reports generated by TestNG has very little information.
As we know all know that ExtentReport is an HTML reporting library (open source) which can be integrated with Selenium WebDriver.
In this article, we will teach you how to develop advanced extent reports / integrate Extent Reports with your existing test automation framework.
We assume you have a working knowledge on Selenium,TestNG and Maven.
Let us start now !!!!
Importance of Reporting in a Test Automation Framework :-
IMethodInterceptor is used to alter/modify the list of test methods to be executed by TestNG.
When we implement
IMethodInterceptor interface which has just one method to implement
'intercept(java.util.List, using this method we can reorder the list of test methods and return List of IMethodInstance which TestNG runs. TestNG will now run these test methods in the same order which is found in the returned list.
Listeners facilitates viewers to view responses generated by samplers in the form of tables, graphs, trees or simple text in some log files and also give pictorial access to the data collected by JMeter about those test cases as a Sampler component of JMeter is executed.
To view the details of sampler requests and responses, add either "View Results Tree" or "View Results in table" Listeners to a test plan which displays basic HTML and XML representations of the response. To view the response time graphically, add Graph Results which plots the response times on a graph.
Please visit for the updated article customized emailable report along with screenshots which works perfect for newer versions of testNG and tested with testng latest version 6.14.3
This example was using older testng version.
When ever we execute tests with TestNG, it will generate a default html report with basic information.
Webdriver events are helpful to view the events triggered by webdriver. It also plays an important role in analyzing results and helps us in debugging issues if we encounter any.
Selenium webdriver has ability to track different events such as 'beforeNavigateTo' , 'afterNavigateTo' , 'beforeClickOn' , 'afterClickOn', 'onException' and so on. When ever we develop test scripts we can write our own implementation for handling events during the execution.
In this tutorial, we will see taking a screen shot with test name and placing it in a folder by creating a folder with Test Class Name.
As we are taking screen shots on failure, we need to add logic in creating a screen shot and naming it with test name and place it in its test class name respectively.
We can get the test class name using 'result.getInstanceName()'. Test class name looks some thing like "com.pack.sample.HomePage". But we need to create a folder name with test class name i.e 'HomePage'.
In TestNG we can generate logs with the help of Listeners. Listeners implement the interface "org.testng.ITestListener". There are methods which gives you a real time information.
What are Listeners in TestNG : -