Top Description Fields Methods
org.junit.platform.engine

public Interface ConfigurationParameters

Known Direct Implementers
org.junit.platform.engine.support.config.PrefixedConfigurationParameters
Annotations
@API
status:STABLE
since:1.0
Static Imports
org.apiguardian.api.API.Status.DEPRECATED, .API.Status.STABLE

Configuration parameters that TestEngines may use to influence test discovery and execution.

For example, the JUnit Jupiter engine uses a configuration parameter to enable IDEs and build tools to deactivate conditional test execution.

As of JUnit Platform 1.8, configuration parameters are also made available to implementations of the org.junit.platform.launcher.TestExecutionListener API via the org.junit.platform.launcher.TestPlan.

Since
1.0
See Also
TestEngine, EngineDiscoveryRequest, ExecutionRequest

Field Summary

Modifier and TypeField and Description
public static final String
CONFIG_FILE_NAME

Name of the JUnit Platform configuration file: junit-platform.properties.

Method Summary

Modifier and TypeMethod and Description
public Optional<String>

Returns:

an Optional containing the value; never null but potentially empty
get
(String
the key to look up; never null or blank
key
)

Get the configuration parameter stored under the specified key.

public default <T> Optional<T>

Returns:

an Optional containing the value; never null but potentially empty
get
(String
the key to look up; never null or blank
key
,
Function<String, T>
the transformer to apply in case a value is found; never null
transformer
)

Get and transform the configuration parameter stored under the specified key using the specified transformer.

public Optional<Boolean>

Returns:

an Optional containing the value; never null but potentially empty
getBoolean
(String
the key to look up; never null or blank
key
)

Get the boolean configuration parameter stored under the specified key.

public Set<String>

Returns:

the set of keys contained in this ConfigurationParameters
keySet
()

Get the keys of all configuration parameters stored in this ConfigurationParameters.

public int
size()

Deprecated as of JUnit Platform 1.9 in favor of keySet()
Get the number of configuration parameters stored directly in this ConfigurationParameters.

Field Detail

CONFIG_FILE_NAMEback to summary
public static final String CONFIG_FILE_NAME

Name of the JUnit Platform configuration file: junit-platform.properties.

If a properties file with this name is present in the root of the classpath, it will be used as a source for configuration parameters. If multiple files are present, only the first one detected in the classpath will be used.

See Also
java.util.Properties

Method Detail

getback to summary
public Optional<String> get(String key)

Get the configuration parameter stored under the specified key.

If no such key is present in this ConfigurationParameters, an attempt will be made to look up the value as a JVM system property. If no such system property exists, an attempt will be made to look up the value in the JUnit Platform properties file.

Parameters
key:String

the key to look up; never null or blank

Returns:Optional<String>

an Optional containing the value; never null but potentially empty

See Also
getBoolean(String), System#getProperty(String), CONFIG_FILE_NAME
getback to summary
public default <T> Optional<T> get(String key, Function<String, T> transformer)

Get and transform the configuration parameter stored under the specified key using the specified transformer.

If no such key is present in this ConfigurationParameters, an attempt will be made to look up the value as a JVM system property. If no such system property exists, an attempt will be made to look up the value in the JUnit Platform properties file.

In case the transformer throws an exception, it will be wrapped in a JUnitException with a helpful message.

Parameters
key:String

the key to look up; never null or blank

transformer:Function<String, T>

the transformer to apply in case a value is found; never null

Returns:Optional<T>

an Optional containing the value; never null but potentially empty

Annotations
@API
status:STABLE
since:1.3
Since
1.3
See Also
getBoolean(String), System#getProperty(String), CONFIG_FILE_NAME
getBooleanback to summary
public Optional<Boolean> getBoolean(String key)

Get the boolean configuration parameter stored under the specified key.

If no such key is present in this ConfigurationParameters, an attempt will be made to look up the value as a JVM system property. If no such system property exists, an attempt will be made to look up the value in the JUnit Platform properties file.

Parameters
key:String

the key to look up; never null or blank

Returns:Optional<Boolean>

an Optional containing the value; never null but potentially empty

See Also
get(String), Boolean#parseBoolean(String), System#getProperty(String), CONFIG_FILE_NAME
keySetback to summary
public Set<String> keySet()

Get the keys of all configuration parameters stored in this ConfigurationParameters.

Returns:Set<String>

the set of keys contained in this ConfigurationParameters

Annotations
@API
status:STABLE
since:1.9
sizeback to summary
public int size()

Deprecated

as of JUnit Platform 1.9 in favor of keySet()

Get the number of configuration parameters stored directly in this ConfigurationParameters.

Annotations
@Deprecated
@API
status:DEPRECATED
since:1.9