Skip to content

JSON Archive breaks after first Test #333

@realulim

Description

@realulim

When using the ExtentSparkReporter and the JsonFormatter to create a JSON archive, so tests from subsequent test runs can be appended to the report, the following bug appears:

All text from report items with a screenshot disappear from the first test run.

Take a look at the enclosed screenshot. It shows the JSON archive after the first run (left) diffed against the JSON archive after the second run (right). As you can see the text "Text with Screenshot" has been deleted from the first report. Interestingly, the "Text without Screenshot" was retained.

screenshot

I tried to write a test for this bug, but ultimately couldn't get the checked out code to compile in my IDE (Netbeans). I will include the bare bones of my test. It has no Asserts, but it will produce the faulty JSON archive:

    @Test
    public void appendWithSparkReporter() throws IOException {
        for (int i = 0; i < 2; i++) {
            String reportPath = "target/append/index.html";
            String jsonPath = "target/append/index.json";
            ExtentSparkReporter sparkReporter = new ExtentSparkReporter(reportPath);
            JsonFormatter jsonReporter = new JsonFormatter(jsonPath);
            ExtentReports extent = new ExtentReports();
            extent.createDomainFromJsonArchive(jsonPath);
            extent.attachReporter(jsonReporter, sparkReporter);
            Media screenshot = MediaEntityBuilder.createScreenCaptureFromPath("img.png").build();
            ExtentTest test = extent.createTest("Testname1", "description1")
                    .log(Status.INFO, "Text without Screenshot", null, null)
                    .log(Status.INFO, "Text with Screenshot", null, screenshot);
            extent.flush();
        }
        // TODO write Asserts to show that "Text with Screenshot" from the first test run is still present.
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions