Top Description Methods
org.junit.jupiter.api

public Interface TestReporter

Annotations
@FunctionalInterface
@API
status:STABLE
since:5.0
Static Imports
java.nio.file.StandardCopyOption.REPLACE_EXISTING, org.apiguardian.api.API.Status.DEPRECATED, .API.Status.MAINTAINED, .API.Status.STABLE

Parameters of type TestReporter can be injected into @BeforeEach and @AfterEach lifecycle methods as well as methods annotated with @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, etc.

Within such methods the injected TestReporter can be used to publish report entries for the current container or test to the reporting infrastructure.

Since
5.0
See Also
publishEntry(Map), publishEntry(String, String)

Method Summary

Modifier and TypeMethod and Description
public default void
publishDirectory(Path
the directory to be published; never null
directory
)

Publish the supplied directory and attach it to the current test or container.

public default void
publishDirectory(String
the name of the directory to be published; never null or blank and must not contain any path separators
name
,
ThrowingConsumer<Path>
the action to be executed to write to the directory; never null
action
)

Publish a directory with the supplied name written by the supplied action and attach it to the current test or container.

public void
publishEntry(Map<String, String>
the key-value pairs to be published; never null; keys and values within entries in the map also must not be null or blank
map
)

Publish the supplied map of key-value pairs as a report entry.

public default void
publishEntry(String
the key of the entry to publish; never null or blank
key
,
String
the value of the entry to publish; never null or blank
value
)

Publish the supplied key-value pair as a report entry.

public default void
publishEntry(String
the value to be published; never null or blank
value
)

Publish the supplied value as a report entry.

public default void
publishFile(Path
the file to be published; never null
file
,
MediaType
the media type of the file; never null; use org.junit.jupiter.api.extension.MediaType#APPLICATION_OCTET_STREAM if unknown
mediaType
)
Deprecated for removal since 5.14. Use publishFile(Path, MediaType) instead.

Publish the supplied file and attach it to the current test or container.

public default void
publishFile(Path
the file to be published; never null
file
,
MediaType
the media type of the file; never null; use MediaType#APPLICATION_OCTET_STREAM if unknown
mediaType
)

Publish the supplied file and attach it to the current test or container.

public default void
publishFile(String
the name of the file to be published; never null or blank and must not contain any path separators
name
,
MediaType
the media type of the file; never null; use org.junit.jupiter.api.extension.MediaType#APPLICATION_OCTET_STREAM if unknown
mediaType
,
ThrowingConsumer<Path>
the action to be executed to write the file; never null
action
)
Deprecated for removal since 5.14. Use publishFile(String, MediaType, ThrowingConsumer) instead.

Publish a file with the supplied name and media type written by the supplied action and attach it to the current test or container.

public default void
publishFile(String
the name of the file to be published; never null or blank and must not contain any path separators
name
,
MediaType
the media type of the file; never null; use MediaType#APPLICATION_OCTET_STREAM if unknown
mediaType
,
ThrowingConsumer<Path>
the action to be executed to write the file; never null
action
)

Publish a file with the supplied name and media type written by the supplied action and attach it to the current test or container.

Method Detail

publishDirectoryback to summary
public default void publishDirectory(Path directory)

Publish the supplied directory and attach it to the current test or container.

The entire directory will be copied to the report output directory replacing any potentially existing files with the same name.

Parameters
directory:Path

the directory to be published; never null

Annotations
@API
status:MAINTAINED
since:5.13.3
Since
5.12
publishDirectoryback to summary
public default void publishDirectory(String name, ThrowingConsumer<Path> action)

Publish a directory with the supplied name written by the supplied action and attach it to the current test or container.

The Path passed to the supplied action will be relative to the report output directory and will point to an existing directory, but it is up to the action to write files to the directory.

Parameters
name:String

the name of the directory to be published; never null or blank and must not contain any path separators

action:ThrowingConsumer<Path>

the action to be executed to write to the directory; never null

Annotations
@API
status:MAINTAINED
since:5.13.3
Since
5.12
publishEntryback to summary
public void publishEntry(Map<String, String> map)

Publish the supplied map of key-value pairs as a report entry.

Parameters
map:Map<String, String>

the key-value pairs to be published; never null; keys and values within entries in the map also must not be null or blank

See Also
publishEntry(String, String), publishEntry(String)
publishEntryback to summary
public default void publishEntry(String key, String value)

Publish the supplied key-value pair as a report entry.

Parameters
key:String

the key of the entry to publish; never null or blank

value:String

the value of the entry to publish; never null or blank

See Also
publishEntry(Map), publishEntry(String)
publishEntryback to summary
public default void publishEntry(String value)

Publish the supplied value as a report entry.

This method delegates to publishEntry(String, String), supplying "value" as the key and the supplied value argument as the value.

Parameters
value:String

the value to be published; never null or blank

Annotations
@API
status:STABLE
since:5.3
Since
5.3
See Also
publishEntry(Map), publishEntry(String, String)
publishFileback to summary
public default void publishFile(Path file, MediaType mediaType)

Deprecated

for removal since 5.14.

Use publishFile(Path, MediaType) instead.

Publish the supplied file and attach it to the current test or container.

The file will be copied to the report output directory replacing any potentially existing file with the same name.

Parameters
file:Path

the file to be published; never null

mediaType:MediaType

the media type of the file; never null; use org.junit.jupiter.api.extension.MediaType#APPLICATION_OCTET_STREAM if unknown

Annotations
@Deprecated
since:5.14
forRemoval:true
@API
status:DEPRECATED
since:5.14
@SuppressWarnings:removal
Since
5.12
publishFileback to summary
public default void publishFile(Path file, MediaType mediaType)

Publish the supplied file and attach it to the current test or container.

The file will be copied to the report output directory replacing any potentially existing file with the same name.

Parameters
file:Path

the file to be published; never null

mediaType:MediaType

the media type of the file; never null; use MediaType#APPLICATION_OCTET_STREAM if unknown

Annotations
@API
status:MAINTAINED
since:5.14
Since
5.14
publishFileback to summary
public default void publishFile(String name, MediaType mediaType, ThrowingConsumer<Path> action)

Deprecated

for removal since 5.14.

Use publishFile(String, MediaType, ThrowingConsumer) instead.

Publish a file with the supplied name and media type written by the supplied action and attach it to the current test or container.

The Path passed to the supplied action will be relative to the report output directory, but it is up to the action to write the file.

Parameters
name:String

the name of the file to be published; never null or blank and must not contain any path separators

mediaType:MediaType

the media type of the file; never null; use org.junit.jupiter.api.extension.MediaType#APPLICATION_OCTET_STREAM if unknown

action:ThrowingConsumer<Path>

the action to be executed to write the file; never null

Annotations
@Deprecated
since:5.14
forRemoval:true
@API
status:DEPRECATED
since:5.14
@SuppressWarnings:removal
Since
5.12
publishFileback to summary
public default void publishFile(String name, MediaType mediaType, ThrowingConsumer<Path> action)

Publish a file with the supplied name and media type written by the supplied action and attach it to the current test or container.

The Path passed to the supplied action will be relative to the report output directory, but it is up to the action to write the file.

Parameters
name:String

the name of the file to be published; never null or blank and must not contain any path separators

mediaType:MediaType

the media type of the file; never null; use MediaType#APPLICATION_OCTET_STREAM if unknown

action:ThrowingConsumer<Path>

the action to be executed to write the file; never null

Annotations
@API
status:MAINTAINED
since:5.14
Since
5.14