How to combine ExtentReports for multiple JUnit5 test classes into one HTML file?

913 Views Asked by At

I'm using ExtentReports (version 5.0.5) with JUnit 5. Here is my BaseTest class snippet.

public class BaseTest
{
    protected static ExtentReports extent;
    protected ExtentTest test;
    protected ExtentTest node;

    @BeforeAll
    static void oneTimeSetup()
    {
        extent = new ExtentReports();
        ExtentSparkReporter spark = new ExtentSparkReporter(
                "target/results" + TimestampGenerator.currentTimestamp() + ".html");
        extent.attachReporter(spark);
    }

    @AfterAll
    static void oneTimeTearDown() throws Exception
    {
        extent.flush();
    }
}

I have 2 test classes in the suite. If I do not use the timestamp in the report name, the program creates one report for the last test class. That's why I added the timestamp. Now when I run the suite in Eclipse, it creates 2 HTML reports for each test class in the suite.

enter image description here

How can I have only one file that contains info for both test classes?

1

There are 1 best solutions below

0
On

You can write a separate class which will read the contents of both reports and create a new HTML report with contents of both files.