Skip to content

Commit 7dec634

Browse files
committed
Document in User Guide and release notes
1 parent 69403c1 commit 7dec634

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

documentation/src/docs/asciidoc/link-attributes.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ endif::[]
4040
:DiscoverySelectors_selectPackage: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/DiscoverySelectors.html#selectPackage(java.lang.String)[selectPackage]
4141
:DiscoverySelectors_selectUniqueId: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/DiscoverySelectors.html#selectUniqueId(java.lang.String)[selectUniqueId]
4242
:DiscoverySelectors_selectUri: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/DiscoverySelectors.html#selectUri(java.lang.String)[selectUri]
43+
:EngineDiscoveryRequest: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/EngineDiscoveryRequest.html[EngineDiscoveryRequest]
4344
:FileSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/FileSelector.html[FileSelector]
4445
:HierarchicalTestEngine: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/support/hierarchical/HierarchicalTestEngine.html[HierarchicalTestEngine]
4546
:IterationSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/IterationSelector.html[IterationSelector]
4647
:MethodSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/MethodSelector.html[MethodSelector]
4748
:ModuleSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/ModuleSelector.html[ModuleSelector]
4849
:NestedClassSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/NestedClassSelector.html[NestedClassSelector]
4950
:NestedMethodSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/NestedMethodSelector.html[NestedMethodSelector]
51+
:OutputDirectoryProvider: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/reporting/OutputDirectoryProvider.html[OutputDirectoryProvider]
5052
:PackageSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/PackageSelector.html[PackageSelector]
5153
:ParallelExecutionConfigurationStrategy: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/support/hierarchical/ParallelExecutionConfigurationStrategy.html[ParallelExecutionConfigurationStrategy]
5254
:UniqueIdSelector: {javadoc-root}/org.junit.platform.engine/org/junit/platform/engine/discovery/UniqueIdSelector.html[UniqueIdSelector]

documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ JUnit repository on GitHub.
4040
`--select-file` and `--select-resource`.
4141
* `ConsoleLauncher` now accepts multiple values for all `--select` options.
4242
* Add `--select-unique-id` support to ConsoleLauncher.
43+
* Add `getOutputDirectoryProvider()` method to `EngineDiscoveryRequest` and `TestPlan` to
44+
allow test engines to publish/attach files to containers and tests by calling
45+
`EngineExecutionListener.fileEntryPublished(...)`. Registered `TestExecutionListeners`
46+
can then access these files by overriding the `fileEntryPublished(...)` method.
4347
* The following improvements have been made to the open-test-reporting XML output:
4448
- Information about the Git repository, the current branch, the commit hash, and the
4549
current worktree status are now included in the XML report, if applicable.
4650
- A section containing JUnit-specific metadata about each test/container to the HTML
4751
report is now written by open-test-reporting when added to the classpath/module path
52+
- Information about published files is now included as attachments.
4853

4954

5055
[[release-notes-5.12.0-M1-junit-jupiter]]
@@ -112,6 +117,8 @@ JUnit repository on GitHub.
112117
* When enabled via the `junit.jupiter.execution.timeout.threaddump.enabled` configuration
113118
parameter, an implementation of `PreInterruptCallback` is registered that writes a
114119
thread dump to `System.out` prior to interrupting a test thread due to a timeout.
120+
* `TestReporter` now allows publishing files for a test method or test class which can be
121+
used to include them in test reports, such as the Open Test Reporting format.
115122

116123

117124
[[release-notes-5.12.0-M1-junit-vintage]]

documentation/src/docs/asciidoc/user-guide/advanced-topics/junit-platform-reporting.adoc

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,46 @@
33

44
The `junit-platform-reporting` artifact contains `{TestExecutionListener}` implementations
55
that generate XML test reports in two flavors:
6-
<<junit-platform-reporting-legacy-xml, legacy>> and
7-
<<junit-platform-reporting-open-test-reporting, Open Test Reporting>>.
6+
<<junit-platform-reporting-open-test-reporting, Open Test Reporting>> and
7+
<<junit-platform-reporting-legacy-xml, legacy>>.
88

99
NOTE: The module also contains other `TestExecutionListener` implementations that can be
1010
used to build custom reporting. See <<running-tests-listeners>> for details.
1111

12-
[[junit-platform-reporting-legacy-xml]]
13-
==== Legacy XML format
12+
[[junit-platform-reporting-output-directory]]
13+
==== Output Directory
1414

15-
`{LegacyXmlReportGeneratingListener}` generates a separate XML report for each root in the
16-
`{TestPlan}`. Note that the generated XML format is compatible with the de facto standard
17-
for JUnit 4 based test reports that was made popular by the Ant build system.
15+
The JUnit Platform provides an `{OutputDirectoryProvider}` via
16+
`{EngineDiscoveryRequest}` and `{TestPlan}` to registered <<test-engines, test engines>>
17+
and <<running-tests-listeners, listeners>>, respectively. Its root directory can be
18+
configured via the following <<running-tests-config-params, configuration parameter>>:
1819

19-
The `LegacyXmlReportGeneratingListener` is used by the <<running-tests-console-launcher>>
20-
as well.
20+
`junit.platform.reporting.output.dir=<path>`::
21+
Configure the output directory for reporting. By default, `build` is used if a Gradle
22+
build script is found, and `target` if a Maven POM is found; otherwise, the current
23+
working directory is used.
24+
25+
To create a unique output directory per test run, you can use the `\{uniqueNumber}`
26+
placeholder in the path. For example, `reports/junit-\{uniqueNumber}` will create
27+
directories like `reports/junit-8803697269315188212`. This can be useful when using
28+
Gradle's or Maven's parallel execution capabilities which create multiple JVM forks
29+
that run concurrently.
2130

2231
[[junit-platform-reporting-open-test-reporting]]
23-
==== Open Test Reporting XML format
32+
==== Open Test Reporting
2433

2534
`{OpenTestReportGeneratingListener}` writes an XML report for the entire execution in the
2635
event-based format specified by {OpenTestReporting} which supports all features of the
2736
JUnit Platform such as hierarchical test structures, display names, tags, etc.
2837

2938
The listener is auto-registered and can be configured via the following
30-
<<running-tests-config-params>>:
39+
<<running-tests-config-params, configuration parameter>>:
3140

3241
`junit.platform.reporting.open.xml.enabled=true|false`::
3342
Enable/disable writing the report.
34-
`junit.platform.reporting.output.dir=<path>`::
35-
Configure the output directory for the reports. By default, `build` is used if a Gradle
36-
build script is found, and `target` if a Maven POM is found; otherwise, the current
37-
working directory is used.
3843

39-
If enabled, the listener creates an XML report file named
40-
`junit-platform-events-<random-id>.xml` per test run in the configured output directory.
44+
If enabled, the listener creates an XML report file named `open-test-report.xml` in the
45+
configured <<junit-platform-reporting-output-directory, output directory>>.
4146

4247
TIP: The {OpenTestReportingCliTool} can be used to convert from the event-based format to
4348
the hierarchical format which is more human-readable.
@@ -145,3 +150,13 @@ via the `--config-resource` option:
145150
$ java -jar junit-platform-console-standalone-{platform-version}.jar <OPTIONS> \
146151
--config-resource=configuration.properties
147152
----
153+
154+
[[junit-platform-reporting-legacy-xml]]
155+
==== Legacy XML format
156+
157+
`{LegacyXmlReportGeneratingListener}` generates a separate XML report for each root in the
158+
`{TestPlan}`. Note that the generated XML format is compatible with the de facto standard
159+
for JUnit 4 based test reports that was made popular by the Ant build system.
160+
161+
The `LegacyXmlReportGeneratingListener` is used by the <<running-tests-console-launcher>>
162+
as well.

documentation/src/docs/asciidoc/user-guide/writing-tests.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,8 +1077,9 @@ include::{testDir}/example/TestInfoDemo.java[tags=user_guide]
10771077
* `{TestReporterParameterResolver}`: if a constructor or method parameter is of type
10781078
`{TestReporter}`, the `TestReporterParameterResolver` will supply an instance of
10791079
`TestReporter`. The `TestReporter` can be used to publish additional data about the
1080-
current test run. The data can be consumed via the `reportingEntryPublished()` method in
1081-
a `{TestExecutionListener}`, allowing it to be viewed in IDEs or included in reports.
1080+
current test run or attach files to it. The data can be consumed in a
1081+
`{TestExecutionListener}` via the `reportingEntryPublished()` or `fileEntryPublished()`
1082+
method, respectively. This allows them to be viewed in IDEs or included in reports.
10821083
+
10831084
In JUnit Jupiter you should use `TestReporter` where you used to print information to
10841085
`stdout` or `stderr` in JUnit 4. Using `@RunWith(JUnitPlatform.class)` will output all

0 commit comments

Comments
 (0)