extent-framework / extentreports-java

Extent Reporting Library, Java
http://extentreports.com
Apache License 2.0
220 stars 126 forks source link

Missing step name after merge reports #431

Open happy1610 opened 5 months ago

happy1610 commented 5 months ago

In json file, if test doesn't have media base64 Report1.json

the merged report looks good Screenshot 2024-03-12 211355

but if any step contains media base64, the merged report will be missing step name in html file Report1.json

Screenshot 2024-03-12 210643

This is my code for merging report ` File file = new File("ExtentJson"); if (!file.exists()) { file.mkdir(); } String opFolder = file.getPath();

    String path =  "\\src\\test\\java\\com\\";
    String jsonPath =  path + "JsonPath\\";
    //Creating individual Report Number 1
    ExtentSparkReporter spark = new ExtentSparkReporter(path + "Report1.html");
    JsonFormatter json = new JsonFormatter(jsonPath + "Report1.json");
    ExtentReports extent = new ExtentReports();
    extent.createTest("test1").assignCategory("cat").pass("Step 1 from test 1")
            .pass("step 2 from test 1");
    extent.attachReporter(json, spark);
    extent.flush();

    //Creating individual Report Number 2
    ExtentSparkReporter spark2 = new ExtentSparkReporter(path + "Report2.html");
    JsonFormatter json2 = new JsonFormatter(jsonPath + "Report2.json");
    ExtentReports extent2 = new ExtentReports();
    extent2.createTest("test2").assignCategory("cat").pass("Step 1 from test 2")
            .fail("step 2 from test 2");
    extent2.attachReporter(json2, spark2);
    extent2.flush();

    ExtentSparkReporter mergedSpark = new ExtentSparkReporter(path + "spark.html");
    ExtentReports extentMerged = new ExtentReports();

    //Replace below logic to get all the .json files generated by extent in opFolder
    File jsonOPDirectory = new File(jsonPath);
    if (jsonOPDirectory.exists()) {
        Arrays.stream(jsonOPDirectory.listFiles()).forEach(jsonFile -> {

            try {
                extentMerged.createDomainFromJsonArchive(jsonFile.getPath());
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    }

    extentMerged.attachReporter(mergedSpark);
    extentMerged.flush();`