|
3 | 3 |
|
4 | 4 | The `junit-platform-reporting` artifact contains `{TestExecutionListener}` implementations |
5 | 5 | 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>>. |
8 | 8 |
|
9 | 9 | NOTE: The module also contains other `TestExecutionListener` implementations that can be |
10 | 10 | used to build custom reporting. See <<running-tests-listeners>> for details. |
11 | 11 |
|
12 | | -[[junit-platform-reporting-legacy-xml]] |
13 | | -==== Legacy XML format |
| 12 | +[[junit-platform-reporting-output-directory]] |
| 13 | +==== Output Directory |
14 | 14 |
|
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>>: |
18 | 19 |
|
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. |
21 | 30 |
|
22 | 31 | [[junit-platform-reporting-open-test-reporting]] |
23 | | -==== Open Test Reporting XML format |
| 32 | +==== Open Test Reporting |
24 | 33 |
|
25 | 34 | `{OpenTestReportGeneratingListener}` writes an XML report for the entire execution in the |
26 | 35 | event-based format specified by {OpenTestReporting} which supports all features of the |
27 | 36 | JUnit Platform such as hierarchical test structures, display names, tags, etc. |
28 | 37 |
|
29 | 38 | The listener is auto-registered and can be configured via the following |
30 | | -<<running-tests-config-params>>: |
| 39 | +<<running-tests-config-params, configuration parameter>>: |
31 | 40 |
|
32 | 41 | `junit.platform.reporting.open.xml.enabled=true|false`:: |
33 | 42 | 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. |
38 | 43 |
|
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>>. |
41 | 46 |
|
42 | 47 | TIP: The {OpenTestReportingCliTool} can be used to convert from the event-based format to |
43 | 48 | the hierarchical format which is more human-readable. |
@@ -145,3 +150,13 @@ via the `--config-resource` option: |
145 | 150 | $ java -jar junit-platform-console-standalone-{platform-version}.jar <OPTIONS> \ |
146 | 151 | --config-resource=configuration.properties |
147 | 152 | ---- |
| 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. |
0 commit comments