Automation Testing

Extent Reports in Automation Testing – Complete Beginner to Advanced Guide

Extent Reports in Automation Testing – Complete Guide with Java & Maven

By Bhau Automation Lab • Professional Test Reporting for Selenium & Automation Frameworks

🎯 What You Will Learn in This Tutorial

  • What are Extent Reports in automation testing?
  • Benefits of using Extent Reports
  • Maven dependency setup for Extent Reports
  • How to initialize Extent Reports in Java
  • How to create tests in Extent Reports
  • How to flush and generate HTML report

📌 What are Extent Reports?

Extent Reports is an advanced reporting library used in automation testing to generate beautiful, interactive, and detailed HTML reports. It is widely used with Selenium, TestNG, JUnit, and API automation frameworks.

Extent Reports help testers and stakeholders clearly understand test execution status, failures, logs, and screenshots in a professional format.

⭐ Benefits of Extent Reports

  • Professional HTML reports
  • Clear pass, fail, skip status
  • Supports screenshots
  • Easy integration with Selenium and TestNG
  • Improves client and management reporting

📦 Step 1: Maven Dependency Setup


    com.aventstack
    extentreports
    5.0.9

Add this dependency in your pom.xml file to start using Extent Reports in your Java automation project.

⚙ Step 2: Initialize Extent Reports

ExtentSparkReporter spark = new ExtentSparkReporter("target/ExtentReport.html");
ExtentReports extent = new ExtentReports();
extent.attachReporter(spark);

This initializes the Extent Reports engine and sets the report file location.

🧪 Step 3: Create Test in Extent Reports

ExtentTest test = extent.createTest("Login Test");
test.info("Browser opened");
test.pass("Login successful");

Each test you create will be visible as a separate entry in the HTML report.

💾 Step 4: Flush the Report

extent.flush();

flush() writes all the logs into the HTML file and generates the final report. Without this, your report will be empty.


🎯 Complete Working Example

import com.aventstack.extentreports.*;
import com.aventstack.extentreports.reporter.ExtentSparkReporter;

public class ExtentReportDemo {

    public static void main(String[] args) {

        ExtentSparkReporter spark = new ExtentSparkReporter("target/ExtentReport.html");
        ExtentReports extent = new ExtentReports();
        extent.attachReporter(spark);

        ExtentTest test = extent.createTest("Google Test");
        test.info("Launching browser");
        test.pass("Google page opened successfully");

        extent.flush();
    }
}

🏢 Real-World Use Cases

  • Automation frameworks
  • Client reporting
  • CI/CD pipeline reporting
  • Daily regression reports
  • Management dashboards

🎥 Watch Full Video Tutorial

👉 Extent Reports in Automation Testing – Full Tutorial

✅ Key Takeaways

  • Extent Reports improve automation visibility
  • Maven setup is simple and quick
  • Initialization is mandatory
  • Create tests for proper logging
  • Flush generates the final report
Pro Tip: Always flush Extent Reports in @AfterSuite or finally block to avoid missing data.

🚀 Created with ❤️ by Bhau Automation Lab

Back to All Articles