Skip to content

Add the ability to generate additional JUnit 5 test reports#432

Open
amilbourne wants to merge 1 commit into
bazel-contrib:mainfrom
amilbourne:main
Open

Add the ability to generate additional JUnit 5 test reports#432
amilbourne wants to merge 1 commit into
bazel-contrib:mainfrom
amilbourne:main

Conversation

@amilbourne

Copy link
Copy Markdown

This PR stems from issue #410

This adds 2 extra parameters to the java_junit5_test target. They are 'report_generator' and 'report_generator_deps'. This allows the 2 standard JUnit5 reports (legacy & open) to be generated as well as user defined reports.

The additional tests demonstrate how to use the new parameters, which should generate additional reports, rather than changing the existing report (test.xml).

Because open test reporting was only added in JUnit 5.9, I upgraded the JUnit dependencies from 5.8 to 5.9. I think the target should still work fine with JUnit <5.9 as I haven't directly depended on the open reporting generator. The target will obviously fail if you specify open reporting when running against an earlier version of JUnit 5. I upgraded in order to test open reporting, but if the upgrade is a problem then I could remove the test and all would be fine without the upgrade. I could also split the upgrade into a separate commit or PR if that makes it better.

@tjoneslo

tjoneslo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

My concern with this is with the output files generated.

In the default case, when no report engine is specified, this generates a test<something>.xml containing the test results. This outputs into the bazel-testlog directory as a test.log and a test.xml file. I'm not sure what the report generators output and I want to make sure the default files are either not generated, or will not be overwritten or interleaved (with potential breakages).

Otherwise I like this idea and can see it could be very useful.

@amilbourne

Copy link
Copy Markdown
Author

Sorry for my slow response. I did originally try writing some tests to check that the files were generated correctly but this was quite gnarly code as it involved calling a build from a test. I could put this back and you can see if you think it is OK. I will update this PR.

This adds 2 extra parameters to the java_junit5_test target.  They are 'report_generator' and 'report_generator_deps'.  This allows the 2 standard JUnit5 reports (legacy & open) to be generated as well as user defined reports.
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

Successfully merging this pull request may close these issues.

2 participants