Automation Testing

Implement Extent Reports in Java Automation Testing – Step-by-Step Guide

Implement Extent Reports in Java Automation Testing – Complete Practical Guide

By Bhau Automation • Professional Test Reporting with Java & Extent Reports

🎯 What You Will Learn in This Video

  • Maven dependency setup for Extent Reports
  • How to initialize Extent Reports in Java
  • How to create test logs in Extent Reports
  • How to flush and generate final HTML report
  • Best practices for professional reporting

📌 What is Extent Reports?

Extent Reports is one of the most powerful reporting libraries used in automation testing. It helps generate beautiful, detailed, and interactive HTML reports for Selenium, TestNG, and API automation projects.

📦 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 project.

⚙ Step 2: Initialize Extent Reports

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

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

🧪 Step 3: Create Test in Extent Reports

ExtentTest test = extent.createTest("Login Test");
test.info("Browser Launched");
test.pass("Login Successful");

Here we are creating a test and adding logs which will be visible in the HTML report.

💾 Step 4: Flush the Report

extent.flush();

flush() is mandatory. It writes all logs into the HTML file and generates the final report.


🎯 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 Launch Test");
        test.info("Chrome browser opened");
        test.pass("Google page loaded successfully");

        extent.flush();
    }
}

📈 Why Use Extent Reports?

  • Professional HTML reports
  • Easy to understand logs
  • Supports screenshots
  • Works with TestNG, JUnit, Selenium, API
  • Industry standard reporting tool

🏢 Real-World Use Cases

  • Automation frameworks
  • Client reporting
  • CI/CD pipeline reporting
  • Test execution analysis
  • Management dashboards

🎥 Watch Full Video Tutorial

👉 Implement Extent Reports in Java Automation Testing

✅ Key Takeaways

  • Maven setup is the first step
  • Initialization is mandatory
  • Create test logs for visibility
  • Flush to generate report
  • Extent Reports make automation professional
Pro Tip: Always flush your report in @AfterSuite or finally block to avoid empty reports.

🚀 Created with ❤️ by Bhau Automation

Back to All Articles