Skip to content

Commit b8fc2f5

Browse files
committed
Add Javadoc
1 parent bcadef0 commit b8fc2f5

File tree

6 files changed

+79
-9
lines changed

6 files changed

+79
-9
lines changed

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ExtensionContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ default void publishReportEntry(String value) {
371371
* Publish a file with the supplied name written by the supplied action and
372372
* attach it to the current test or container.
373373
* <p>
374-
* The file will be located in the report output directory prior to invoking
375-
* the supplied action.
374+
* The file will be resolved in the report output directory prior to
375+
* invoking the supplied action.
376376
*
377377
* @param fileName the name of the file to be attached; never {@code null} or blank
378378
* and must not contain any path separators

junit-platform-engine/src/main/java/org/junit/platform/engine/EngineDiscoveryRequest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
package org.junit.platform.engine;
1212

13+
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
1314
import static org.apiguardian.api.API.Status.STABLE;
1415

1516
import java.util.List;
@@ -74,10 +75,6 @@ public interface EngineDiscoveryRequest {
7475
/**
7576
* Get the {@link EngineDiscoveryListener} for this request.
7677
*
77-
* <p>The default implementation returns a no-op listener that ignores all
78-
* calls so that engines that call this methods can be used with an earlier
79-
* version of the JUnit Platform that did not yet include this API.
80-
*
8178
* @return the discovery listener; never {@code null}
8279
* @since 1.6
8380
*/
@@ -86,6 +83,13 @@ default EngineDiscoveryListener getDiscoveryListener() {
8683
return EngineDiscoveryListener.NOOP;
8784
}
8885

86+
/**
87+
* Get the {@link OutputDirectoryProvider} for this request.
88+
*
89+
* @return the output directory provider; never {@code null}
90+
* @since 1.12
91+
*/
92+
@API(status = EXPERIMENTAL, since = "1.12")
8993
default OutputDirectoryProvider getOutputDirectoryProvider() {
9094
throw new JUnitException(
9195
"OutputDirectoryProvider not available; probably due to unaligned versions of the junit-platform-engine and junit-platform-launcher jars on the classpath/module path.");

junit-platform-engine/src/main/java/org/junit/platform/engine/EngineExecutionListener.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ default void executionFinished(TestDescriptor testDescriptor, TestExecutionResul
139139
default void reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry) {
140140
}
141141

142+
/**
143+
* Can be called for any {@link TestDescriptor} in order to attach a file to
144+
* a test or container &mdash; for example:
145+
*
146+
* <ul>
147+
* <li>Screenshots</li>
148+
* <li>Logs</li>
149+
* <li>Output files written by the code under test</li>
150+
* </ul>
151+
*
152+
* <p>The current lifecycle state of the supplied {@code TestDescriptor} is
153+
* not relevant: file events can occur at any time.
154+
*
155+
* @param testDescriptor the descriptor of the test or container to which
156+
* the file entry belongs
157+
* @param file a {@code FileEntry} instance to be attached
158+
*/
142159
@API(status = EXPERIMENTAL, since = "1.12")
143160
default void fileEntryPublished(TestDescriptor testDescriptor, FileEntry file) {
144161
}

junit-platform-engine/src/main/java/org/junit/platform/engine/reporting/FileEntry.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import org.junit.platform.commons.util.ToStringBuilder;
2121

2222
/**
23-
* {@code FileEntry} encapsulates a file to be published to the reporting infrastructure.
23+
* {@code FileEntry} encapsulates a file to be published to the reporting
24+
* infrastructure.
2425
*
25-
* @since 1.11
26+
* @since 1.12
2627
* @see #from(Path)
2728
*/
28-
@API(status = EXPERIMENTAL, since = "1.11")
29+
@API(status = EXPERIMENTAL, since = "1.12")
2930
public final class FileEntry {
3031

3132
/**
@@ -53,6 +54,11 @@ public LocalDateTime getTimestamp() {
5354
return this.timestamp;
5455
}
5556

57+
/**
58+
* Get the file to be published.
59+
*
60+
* @return the file to publish; never {@code null}
61+
*/
5662
public Path getFile() {
5763
return file;
5864
}

junit-platform-engine/src/main/java/org/junit/platform/engine/reporting/OutputDirectoryProvider.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,32 @@
1616
import java.nio.file.Path;
1717

1818
import org.apiguardian.api.API;
19+
import org.junit.platform.engine.EngineDiscoveryRequest;
1920
import org.junit.platform.engine.TestDescriptor;
2021

22+
/**
23+
* Provider of output directories for test engines to write reports and other
24+
* output files to.
25+
*
26+
* @since 1.12
27+
* @see EngineDiscoveryRequest#getOutputDirectoryProvider()
28+
*/
2129
@API(status = EXPERIMENTAL, since = "1.12")
2230
public interface OutputDirectoryProvider {
2331

32+
/**
33+
* {@return the root directory for all output files}
34+
*/
2435
Path getRootDirectory();
2536

37+
/**
38+
* Create an output directory for the supplied test descriptor.
39+
*
40+
* @param testDescriptor the test descriptor for which to create an output
41+
* directory
42+
* @return the output directory
43+
* @throws IOException if the output directory could not be created
44+
*/
2645
Path createOutputDirectory(TestDescriptor testDescriptor) throws IOException;
2746

2847
}

junit-platform-launcher/src/main/java/org/junit/platform/launcher/LauncherConstants.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,32 @@ public class LauncherConstants {
191191
@API(status = EXPERIMENTAL, since = "1.10")
192192
public static final String STACKTRACE_PRUNING_ENABLED_PROPERTY_NAME = "junit.platform.stacktrace.pruning.enabled";
193193

194+
/**
195+
* Property name used to configure the output directory for reporting.
196+
*
197+
* <p>If set, value must be a valid path that will be created if it doesn't
198+
* exist. If not set, the default output directory will be determined by the
199+
* reporting engine based on the current working directory.
200+
*
201+
* @since 1.12
202+
* @see #OUTPUT_DIR_UNIQUE_NUMBER_PLACEHOLDER
203+
* @see org.junit.platform.engine.reporting.OutputDirectoryProvider
204+
*/
205+
@API(status = EXPERIMENTAL, since = "1.12")
194206
public static final String OUTPUT_DIR_PROPERTY_NAME = "junit.platform.reporting.output.dir";
195207

208+
/**
209+
* Placeholder for use in {@link #OUTPUT_DIR_PROPERTY_NAME} that will be
210+
* replaced with a unique number.
211+
*
212+
* <p>This can be used to create a unique output directory for each test
213+
* run. For example, if multiple forks are used, each fork can be configured
214+
* to write its output to a separate directory.
215+
*
216+
* @since 1.12
217+
* @see #OUTPUT_DIR_PROPERTY_NAME
218+
*/
219+
@API(status = EXPERIMENTAL, since = "1.12")
196220
public static final String OUTPUT_DIR_UNIQUE_NUMBER_PLACEHOLDER = "{uniqueNumber}";
197221

198222
private LauncherConstants() {

0 commit comments

Comments
 (0)