Complete Guide to Extent Reports in Selenium Automation Testing (Java + Maven)
By Bhau Automation Lab โข Beginner to Advanced Extent Reports Tutorial
๐ฏ What You Will Learn in This Tutorial
- What are Extent Reports in automation testing?
- Benefits of using Extent Reports
- Maven dependency setup step-by-step
- How to initialize Extent Reports in Java
- How to create tests using Extent Reports
- How to flush and generate final report
๐ What are Extent Reports?
Extent Reports is a powerful reporting library used in Selenium automation testing to generate detailed, interactive, and visually appealing HTML reports. It helps testers and stakeholders easily understand test execution results.
Extent Reports provide complete visibility of test steps, logs, screenshots, and execution status in a professional format.
โญ Benefits of Extent Reports
- Professional and attractive HTML reports
- Clear pass, fail, skip status
- Supports screenshots on failure
- Easy integration with Selenium & TestNG
- Improves automation framework quality
- Client and management friendly reports
๐ฆ Step 1: Maven Dependency Setup
com.aventstack extentreports 5.0.9
Add this dependency in your pom.xml file to use Extent Reports in your automation project.
โ Step 2: Initialize Extent Reports
ExtentSparkReporter spark = new ExtentSparkReporter("target/ExtentReport.html");
ExtentReports extent = new ExtentReports();
extent.attachReporter(spark);
This initializes Extent Reports and sets the path where the report will be generated.
๐งช Step 3: Creating Tests in Extent Reports
ExtentTest test = extent.createTest("Login Test");
test.info("Opening browser");
test.pass("Login successful");
Each test will appear as a separate entry in the Extent HTML report.
๐พ Step 4: Flush the Report
extent.flush();
flush() is mandatory. It writes all the logs into the HTML file and generates the final report. If you forget 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("Demo Test");
test.info("Starting test execution");
test.pass("Test executed successfully");
extent.flush();
}
}
๐ข Real-World Use Cases
- Selenium automation frameworks
- Regression testing reports
- CI/CD pipeline reporting
- Client demo reports
- Daily execution dashboards
๐ฅ Watch Full Video Tutorial
๐ Watch: Complete Guide to Extent Reports in Automation Testing
โ Key Takeaways
- Extent Reports make automation reports professional
- Maven setup is quick and easy
- Initialization is mandatory
- flush() generates the final HTML report
- Essential skill for automation testers
โก Pro Tip: Always use extent.flush() in @AfterSuite to avoid missing logs.
๐ Created with โค๏ธ by Bhau Automation Lab