I have made a script to generate an extent report, but HTML is not generated.

Please check below code:

package report;

import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.markuputils.ExtentColor;
import com.aventstack.extentreports.markuputils.MarkupHelper;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.configuration.ChartLocation;
import com.aventstack.extentreports.reporter.configuration.Theme;

public class Report {

    ExtentHtmlReporter htmlReporter;
     static ExtentReports extent;
     static ExtentTest logger;

     public void startReport(){

     htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir") +"/test-output/STMExtentReport.html");
     extent = new ExtentReports ();
     extent.setSystemInfo("Host Name", "SoftwareTestingMaterial");
     extent.setSystemInfo("Environment", "Automation Testing");
     extent.setSystemInfo("User Name", "Rajkumar SM");

     htmlReporter.config().setDocumentTitle("Title of the Report Comes here");
     htmlReporter.config().setReportName("Name of the Report Comes here");

     public void passTest(){
     logger = extent.createTest("passTest");
     logger.log(Status.PASS, MarkupHelper.createLabel("Test Case Passed is passTest", ExtentColor.GREEN));

     public void failTest(){
     logger = extent.createTest("failTest");
     logger.log(Status.PASS, "Test Case (failTest) Status is passed");
     logger.log(Status.PASS, MarkupHelper.createLabel("Test Case (failTest) Status is passed", ExtentColor.GREEN));

     public void skipTest(){
     logger = extent.createTest("skipTest");
     throw new SkipException("Skipping - This is not ready for testing ");

     public void getResult(ITestResult result){
     if(result.getStatus() == ITestResult.FAILURE){
     //logger.log(Status.FAIL, "Test Case Failed is "+result.getName());
     //MarkupHelper is used to display the output in different colors
     logger.log(Status.FAIL, MarkupHelper.createLabel(result.getName() + " - Test Case Failed", ExtentColor.RED));
     logger.log(Status.FAIL, MarkupHelper.createLabel(result.getThrowable() + " - Test Case Failed", ExtentColor.RED));
     }else if(result.getStatus() == ITestResult.SKIP){
     //logger.log(Status.SKIP, "Test Case Skipped is "+result.getName());
     logger.log(Status.SKIP, MarkupHelper.createLabel(result.getName() + " - Test Case Skipped", ExtentColor.ORANGE)); 
     public void endReport(){


The .xml file :

<?xml version="1.0" encoding="UTF-8"?>
        <!-- report theme -->
        <!-- standard, dark -->

        <!-- document encoding -->
        <!-- defaults to UTF-8 -->

        <!-- protocol for script and stylesheets -->
        <!-- defaults to https -->

        <!-- title of the document -->

        <!-- report name - displayed at top-nav -->
        <reportName>Automation Report</reportName>

        <!-- location of charts in the test view -->
        <!-- top, bottom -->

        <!-- custom javascript -->
                $(document).ready(function() {


        <!-- custom styles -->

  • your startReport() method is @BeforeTest so it will execute before each test class and each time it will override the old HTML file, and your last Test is throwing skipexception. May 2, 2019 at 10:59
  • ok then what should i have to do@upkar Singh
    – Rutvi Soni
    May 2, 2019 at 11:34
  • is your empty HTML file has been created in your test-output folder? if not then is it throwing any exception ? May 2, 2019 at 11:51
  • i have encountered the same problem when using TestNG version "7.0.0". Try to use version 6.14.3. PS: ExtentReports version that i'm using is "3.1.5". Aug 29, 2019 at 13:54

1 Answer 1


I have created an example on the basis of your code, please note that here i'm using the Extent Report Version 3 so change your code accordingly.
I hope this code help you-

public class Report  {

     static ExtentTest logger;
     static ExtentReports extent;
     static ExtentHtmlReporter reporter;
    public void startreport() {

        extent = new ExtentReports();       
        extent.setSystemInfo("Host Name", "SoftwareTestingMaterial");
        extent.setSystemInfo("Environment", "Automation Testing");
        extent.setSystemInfo("User Name", "Rajkumar SM");               
     public ExtentHtmlReporter getHtmlReporter()
        reporter= new ExtentHtmlReporter(System.getProperty("user.dir") +"\\test-output/STMExtentReport.html");
        reporter.config().setDocumentTitle("QA Automation Report");
        reporter.config().setReportName("Regression Testing");
        return reporter;
    public void passTest(){
         logger= extent.createTest("Pass Test", "Login");
    //test steps.
    public void failTest(){
    logger = extent.createTest("failTest", "Login");
     //test steps.

     //other steps

    public void endReport(){

Please refresh your project after run the test.
For the more information about report please check Here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.