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

Does the current Serenity framework allows Junit XML file to generate TestOutcome object instead of using the test execution json file #2455

Closed
zhenwei94 opened this issue May 12, 2021 · 6 comments

Comments

@zhenwei94
Copy link

Hi, I understand that the current version of Serenity is able to generate TestOutcome object from the test execution JSON file. May I know if it is also able to generate the same using Junit XML file? If so, can you share with me some links for reference. Thanks.

@Manish123chandel
Copy link

Manish123chandel commented May 12, 2021

Hi @wakaleo ,

I go through the code, I can see the TestOutComeLoader class which is basically to load the data is restricted to use of only .Json file.
Code snnipet is given below from the library.

 private List<File> getAllOutcomeFilesFrom(final File reportsDirectory) throws IOException
        {
        File[] matchingFiles = reportsDirectory.listFiles(**new SerializedOutcomeFilenameFilter()**);

        if (matchingFiles == null) {
            throw new IOException("Could not find directory " + reportsDirectory);
        }
        return NewList.copyOf(matchingFiles);
    }
private class SerializedOutcomeFilenameFilter implements FilenameFilter 
       {
        public boolean accept(final File file, final String filename) {
            return   (filename.toLowerCase(Locale.getDefault())
                    .endsWith(formatConfiguration.getPreferredFormat().getExtension())
                    && (!filename.endsWith(".features.json"))
                    && (!filename.endsWith("manifest.json"))
                    && (!filename.startsWith(JUnitXMLOutcomeReporter.FILE_PREFIX))) ;
        }
    }

above code is just filtering the .json file from your reportsDirectory.

let me know if you are going to support to generate the TestOutComes from Junit .Xml report files?

@wakaleo
Copy link
Member

wakaleo commented May 12, 2021

They are generated automatically, in target/site/serenity, with the prefix "SERENITY-JUNIT

@Manish123chandel
Copy link

Hi @wakaleo ,

Sorry I think our question is different.
We know that Junit file generates in target/site/serenity folder.

We want to know about the when we call to
final TestOutcomes testOutcomes = TestOutcomeLoader.testOutcomesIn(resultsDir);
it construct the list of TestOutCome objects, currently with initial implementation it seems like it only construct the TestOutcome object with use of only .JSON file. as code snippet is above.

but when we execute the test it also generates the Junit .xml file in target/site/serenity folder.

Question: We have restricted the Testoutcome construnction with Json only.
Do we have any plan to create the TestOutCome with the Junit .xml file?

for more details , can refer "net\serenity-bdd\serenity-model\2.4.1\serenity-model-2.4.1.jar!\net\thucydides\core\reports\TestOutcomeLoader.class" .

@wakaleo
Copy link
Member

wakaleo commented May 12, 2021

That isn't currently supported. Why do you need to do that?

@Manish123chandel
Copy link

Actually, We using Jest-Jasmine for angular web app testing, so I am using Jest-Junit JS library to generate the .xml report,
earlier we tried Jest to generate the .JSON report with serenityJS but it seems due to default jasmine2 test runner in jest, its .JSON report is different from the Vanila Jasmine's (Jasmine + SerenityJS).JSON reports for more Issue raise link with Jest().

Due to wrong report generation in Jest for .JSON so We are going with JUnit .XML report, so in future we can integrate this to any test management tools similar like Current implementation with .JSON report exist.

I hope you understand our requirement Why we are going with Junit .XML report.

Just trying to follow serenity Java code, how you manage Junit .xml report in your case as it seems it's not implemented.

@wakaleo
Copy link
Member

wakaleo commented May 22, 2021

It is currently produced as part of the normal output. You could potentially refactor it into a separate report so that it can be activated and deactivated as required - happy to review a PR if you want to take a look.

@wakaleo wakaleo closed this as completed Feb 12, 2022
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

3 participants