Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Archive file balloons with repeated Test Runs #336

Closed
realulim opened this issue Dec 9, 2021 · 2 comments
Closed

JSON Archive file balloons with repeated Test Runs #336

realulim opened this issue Dec 9, 2021 · 2 comments

Comments

@realulim
Copy link

realulim commented Dec 9, 2021

The following test case shows that if I run a test 5 times in a row, there will be 31 tests in the report instead of 5.

    @Test
    public void countAppendedTests() throws IOException {
        ExtentReports extent = new ExtentReports();
        int expectedTestCount = 5;
        String testName = "Unique Test Name " + UUID.randomUUID().toString();
        for (int i = 0; i < expectedTestCount; i++) {
            String reportPath = "target/append/index.html";
            String jsonPath = "target/append/index.json";
            ExtentSparkReporter sparkReporter = new ExtentSparkReporter(reportPath);
            JsonFormatter jsonReporter = new JsonFormatter(jsonPath);
            extent.createDomainFromJsonArchive(jsonPath);
            extent.attachReporter(jsonReporter, sparkReporter);
            extent.createTest(testName).info("some text");
            extent.flush();
        }
        List<com.aventstack.extentreports.model.Test> appendedTests = null;
        appendedTests = extent.getReport().getTestList().stream().filter(t -> {
            return t.getName().equals(testName);
        }).collect(Collectors.toList());
        Assert.assertEquals(appendedTests.size(), expectedTestCount);
    }
@anshooarora
Copy link
Member

This is expected:

  • 1st run: 1 test as there is nothing to create a domain from external file
  • 2nd run: 3 tests
    • 1 test in memory from previous run
    • 1 test parsed from external file
    • 1 new test created
  • 3rd run: 7 tests
    • 3 tests from previous run (in memory)
    • 3 tests parsed from file
    • 1 new test created
      ...
  • 4th run: 15 tests
    ...
  • 5th run: 31 tests

createDomainFromJsonArchive will read from an external file and update the existing collection of tests, so the above test isn't valid. expectedTestCount should be 31.

@realulim
Copy link
Author

The javadocs say that this is the equivalent of the former "appendExisting" option. IIRC that option appended subsequent test runs to the report. This is what I expected here as well. I don't understand the use case you described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants