I am running the multiple automation suites in parallel and those all are creating the different extent reports. I want to my code to read the existing extent reports and create a consolidated one. is there any way to read the 2 extent reports and create a consolidated report by merging the test results?
I tried below code but it is not merging the test results correctly.
I am using 4.0.9 version for Extent Report.
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.configuration.Protocol;
import com.aventstack.extentreports.reporter.configuration.Theme;
public class ExtentReportMerger1 {
public static void main(String[] args) {
String file1Path = "D:\\CodeAutomation15\\ui-automation- codebase\\logs\\Reports\\ExtentReports1.html";
String file2Path = "D:\\CodeAutomation15\\ui-automation-codebase\\logs\\Reports\\ExtentReports2.html";
// Load the first report
ExtentReports extentReports = new ExtentReports();
ExtentHtmlReporter htmlReporter1 = new ExtentHtmlReporter(file1Path);
extentReports.attachReporter(htmlReporter1);
// Load the second report
ExtentHtmlReporter htmlReporter2 = new ExtentHtmlReporter(file2Path);
// Append the details from the second report to the first report
extentReports.attachReporter(htmlReporter2);
htmlReporter1.config().setTheme(Theme.STANDARD);
htmlReporter1.config().setDocumentTitle("Merged Report");
htmlReporter1.config().setEncoding("UTF-8");
htmlReporter1.config().setProtocol(Protocol.HTTPS);
// Flush the reports
extentReports.flush();
System.out.println("Merged Extent reports successfully!");
}
}
I tried the above code and it appended the details from 2nd file to 1st but it was not correctly merged.

You can append multiple reports in Extent
4.1.7version of extent using json files generated by extent If you have the .json file generated by extent Report , we can use those to create a single html report with all merged results Below is a sample where i am running two test cases and generating the json for the extent and them I create a final html from ht generated json For Your use case i would suggest to generate the json for every html report and then in the end you can consolidate into a single reportBelow is a sample use case to Achieve this-
#1 First we create a common output Folder for extent json files so that we can merge them all from a common folder #2 Them we generate two sample html Reports with there extent json files which are then written to common json folder
#3 Then we Create a Third extent Report , Take all the generated json files from folder and add their data into this and it will create a merged Report
Full Code
Reference Combine Multiple Reports