TechBeamersTechBeamers
  • Learn ProgrammingLearn Programming
    • Python Programming
      • Python Basic
      • Python OOP
      • Python Pandas
      • Python PIP
      • Python Advanced
      • Python Selenium
    • Python Examples
    • Selenium Tutorials
      • Selenium with Java
      • Selenium with Python
    • Software Testing Tutorials
    • Java Programming
      • Java Basic
      • Java Flow Control
      • Java OOP
    • C Programming
    • Linux Commands
    • MySQL Commands
    • Agile in Software
    • AngularJS Guides
    • Android Tutorials
  • Interview PrepInterview Prep
    • SQL Interview Questions
    • Testing Interview Q&A
    • Python Interview Q&A
    • Selenium Interview Q&A
    • C Sharp Interview Q&A
    • PHP Interview Questions
    • Java Interview Questions
    • Web Development Q&A
  • Self AssessmentSelf Assessment
    • Python Test
    • Java Online Test
    • Selenium Quiz
    • Testing Quiz
    • HTML CSS Quiz
    • Shell Script Test
    • C/C++ Coding Test
Search
  • Python Multiline String
  • Python Multiline Comment
  • Python Iterate String
  • Python Dictionary
  • Python Lists
  • Python List Contains
  • Page Object Model
  • TestNG Annotations
  • Python Function Quiz
  • Python String Quiz
  • Python OOP Test
  • Java Spring Test
  • Java Collection Quiz
  • JavaScript Skill Test
  • Selenium Skill Test
  • Selenium Python Quiz
  • Shell Scripting Test
  • Latest Python Q&A
  • CSharp Coding Q&A
  • SQL Query Question
  • Top Selenium Q&A
  • Top QA Questions
  • Latest Testing Q&A
  • REST API Questions
  • Linux Interview Q&A
  • Shell Script Questions
© 2024 TechBeamers. All Rights Reserved.
Reading: How do I Merge Two Extent Reports?
Font ResizerAa
TechBeamersTechBeamers
Font ResizerAa
  • Python
  • SQL
  • C
  • Java
  • Testing
  • Selenium
  • Agile Concepts Simplified
  • Linux
  • MySQL
  • Python Quizzes
  • Java Quiz
  • Testing Quiz
  • Shell Script Quiz
  • WebDev Interview
  • Python Basic
  • Python Examples
  • Python Advanced
  • Python OOP
  • Python Selenium
  • General Tech
Search
  • Programming Tutorials
    • Python Tutorial
    • Python Examples
    • Java Tutorial
    • C Tutorial
    • MySQL Tutorial
    • Selenium Tutorial
    • Testing Tutorial
  • Top Interview Q&A
    • SQL Interview
    • Web Dev Interview
  • Best Coding Quiz
    • Python Quizzes
    • Java Quiz
    • Testing Quiz
    • ShellScript Quiz
Follow US
© 2024 TechBeamers. All Rights Reserved.
Selenium Tutorial

How do I Merge Two Extent Reports?

Last updated: Apr 23, 2024 9:13 pm
By Meenakshi Agarwal
Share
7 Min Read
How do I Merge Two Extent Reports?
SHARE

In Selenium automation testing, merging two Extent Reports can be beneficial when you want to consolidate test results from different runs or scenarios into a single comprehensive report. This tutorial will guide you through the detailed process and provide practical examples for quick understanding.

Contents
Merge Extent Reports By Using the CodeSection 1: Setting Up Your ProjectSection 2: Understand Extent ReportsSection 3: Generate Extent ReportsSection 4: Merge ReportsSection 5: Run the Merged ReportUsing Extent Reports FrameworkSummary

Understand How to Merge Two Extent Reports

There are two common ways to achieve our goal. One is by using the code and another is by using the ExtentX UI to merge. Let’s go through both these methods one by one.

Merge Extent Reports By Using the Code

Let’s understand the first method. Here is an in-depth explanation of how you should do it.

Section 1: Setting Up Your Project

Begin by ensuring you have a Selenium project set up with Extent Reports integrated. If you haven’t installed the Extent Reports library, you can do so using your preferred package manager (e.g., Maven or Gradle). Make sure to have the main dependencies in your project.

Must Read:
1. What is Regression Testing? How to Do It? Provide Examples.
2. What is Penetration Testing? How to Do It? Provide Examples.
3. What is the Software Development Life Cycle (SDLC)?
4. What is the Software Testing Life Cycle (STLC)?
5. How to Generate Report in Selenium Webdriver?
6. How to Generate Extent Report in Selenium?
7. How to Zoom In/Out in Selenium Webdriver Using Java?
8. Random API for Postman to Generate Random Inputs

Section 2: Understand Extent Reports

Before diving into merging reports, let’s have a quick overview of Extent Reports. Extent Reports is a reporting library for Selenium WebDriver, offering detailed HTML reports with interactive charts and graphs.

Section 3: Generate Extent Reports

Assuming you have a Selenium test suite that generates Extent Reports after execution, ensure each test class creates its individual Extent Report file. This is crucial for later merging.

Here’s a simplified example of how you can generate Extent Reports in Selenium. In this code, we have two demo tests. Each of them will generate an individual report file.

import statements for extent report generation
import com.aventstack.extentreports.*;
import org.testng.annotations.*;

public class SampleTest {

    private static ExtentReports ext;

    @BeforeSuite
    public void setUp() {
        // No need to config ExtentHtmlReporter for each test method
        extent = new ExtentReports();
    }

    @Test
    public void sampleTestCase1() {
        // Your test logic here

        // Log steps
        ExtentTest demo = ext.createTest("Demo Test 1");
        demo.log(Status.INFO, "Step 1: Do an action");
        demo.log(Status.INFO, "Step 2: Verify the result");
        // Add more logs as needed
    }

    @Test
    public void sampleTestCase2() {
        // Your logic here

        // Log steps
        ExtentTest demo = ext.createTest("Demo Test 2");
        demo.log(Status.INFO, "Step 1: Do another action");
        demo.log(Status.INFO, "Step 2: Verify another result");
        // Add more logs as needed
    }

    @AfterSuite
    public void tearDown() {
        // Flush the Extent Report
        ext.flush();
    }
}

Ensure each test class follows a similar structure, creating its Extent Report file during test execution.

Section 4: Merge Reports

Now, let’s proceed to the core part – merging two Extent Reports. For simplicity, we’ll use the ExtentReports utility class provided by the Extent Reports library.

import statement for merging two extent reports
import com.aventstack.extentreports.*;

public class ReportMerger {

    public static void main(String[] args) {
        try {
            // Create ExtentReports instances
            ExtentReports merged = new ExtentReports();

            // Specify the paths of the reports to be merged
            String rptPath1 = "path/to/first/report.html";
            String rptPath2 = "path/to/second/report.html";

            // Create ExtentHtmlReporter instances for the reports to be merged
            ExtentHtmlReporter rpt1 = new ExtentHtmlReporter(rptPath1);
            ExtentHtmlReporter rpt2 = new ExtentHtmlReporter(rptPath2);

            // Load the reports to be merged
            merged.attachReporter(rpt1, rpt2);

            // Display a message in the merged report
            ExtentTest mergedTest = merged.createTest("Merged Test");
            mergedTest.log(Status.INFO, "This report is a combination of two individual reports.");

            // Flush the merged report
            merged.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Replace "path/to/first/report.html" and "path/to/second/report.html" with the actual paths of the Extent Reports you want to merge. This example creates a new Extent Report file, attaches the reports to be merged, and adds a custom message.

Section 5: Run the Merged Report

Execute the ReportMerger class to generate the merged Extent Report. Open the resulting HTML file in your preferred web browser to view the consolidated results.

Let’s explore another way to merge Extent Reports without delving into code. This method involves using the Extent Reports framework itself. No coding is needed; you just follow some simple steps.

Using Extent Reports Framework

Install ExtentX:

Get ExtentX, a reporting server for Extent Reports, provides historical views of your test runs.

Configure ExtentX:

Set up ExtentX by following its documentation and connecting it to your existing Extent Reports.

Run Tests and Reports:

Run your Selenium scripts as usual, ensuring each run generates a separate Extent Report.

Access ExtentX Dashboard:

Open the ExtentX dashboard in your web browser.

Merge Reports in ExtentX:

ExtentX offers an easy way to merge reports through its user interface.

Head to the “Reports” section and select reports for merge operation. Use the merge option to create a comprehensive report.

This method gives a hassle-free approach for merging two Extent reports without any coding. ExtentX serves as a centralized hub for managing and analyzing your Extent Reports.

Summary

Merging two Extent Reports in Selenium is a valuable practice for aggregating test results. This tutorial aimed to simplify the process, making it accessible for Selenium testers. Feel free to adapt the examples to fit your project’s structure and requirements.

Happy testing!

You Might Also Like

20 Demo Sites for Automation Testing

Page Object Model (POM) and Page Factory Guide in Selenium Java

Selenium 4 Relative Locators Guide

Selenium Version 4 Features – What’s New?

How to Inspect Element in Safari, Android, and iPhone

TAGGED:Selenium Reporting
Meenakshi Agarwal Avatar
By Meenakshi Agarwal
Follow:
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large MNCs, I gained extensive experience in programming, coding, software development, testing, and automation. Now, I share my knowledge through tutorials, quizzes, and interview questions on Python, Java, Selenium, SQL, and C# on my blog, TechBeamers.com.
Previous Article Random API for Postman to Generate Random Inputs for Testing Postman Random APIs to Generate Unique Test Inputs
Next Article What is the difference between extent report and allure report? Difference Between Extent Report and Allure Report

Popular Tutorials

SQL Interview Questions List
50 SQL Practice Questions for Good Results in Interview
SQL Interview Nov 01, 2016
Demo Websites You Need to Practice Selenium
7 Sites to Practice Selenium for Free in 2024
Selenium Tutorial Feb 08, 2016
SQL Exercises with Sample Table and Demo Data
SQL Exercises – Complex Queries
SQL Interview May 10, 2020
Java Coding Questions for Software Testers
15 Java Coding Questions for Testers
Selenium Tutorial Jun 17, 2016
30 Quick Python Programming Questions On List, Tuple & Dictionary
30 Python Programming Questions On List, Tuple, and Dictionary
Python Basic Python Tutorials Oct 07, 2016
//
Our tutorials are written by real people who’ve put in the time to research and test thoroughly. Whether you’re a beginner or a pro, our tutorials will guide you through everything you need to learn a programming language.

Top Coding Tips

  • PYTHON TIPS
  • PANDAS TIPSNew
  • DATA ANALYSIS TIPS
  • SELENIUM TIPS
  • C CODING TIPS
  • GDB DEBUG TIPS
  • SQL TIPS & TRICKS

Top Tutorials

  • PYTHON TUTORIAL FOR BEGINNERS
  • SELENIUM WEBDRIVER TUTORIAL
  • SELENIUM PYTHON TUTORIAL
  • SELENIUM DEMO WEBSITESHot
  • TESTNG TUTORIALS FOR BEGINNERS
  • PYTHON MULTITHREADING TUTORIAL
  • JAVA MULTITHREADING TUTORIAL

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Loading
TechBeamersTechBeamers
Follow US
© 2024 TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
TechBeamers Newsletter - Subscribe for Latest Updates
Join Us!

Subscribe to our newsletter and never miss the latest tech tutorials, quizzes, and tips.

Loading
Zero spam, Unsubscribe at any time.
x