Interface ConfigurationParameters

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONFIG_FILE_NAME
      Name of the JUnit Platform configuration file: "junit-platform.properties".
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.String> get​(java.lang.String key)
      Get the configuration parameter stored under the specified key.
      default <T> java.util.Optional<T> get​(java.lang.String key, java.util.function.Function<java.lang.String,​T> transformer)
      Get and transform the configuration parameter stored under the specified key using the specified transformer.
      java.util.Optional<java.lang.Boolean> getBoolean​(java.lang.String key)
      Get the boolean configuration parameter stored under the specified key.
      java.util.Set<java.lang.String> keySet()
      Get the keys of all configuration parameters stored in this ConfigurationParameters.
      int size()
      Deprecated.
      as of JUnit Platform 1.9 in favor of keySet()
    • Field Detail

      • CONFIG_FILE_NAME

        static final java.lang.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:
        Properties, Constant Field Values
    • Method Detail

      • get

        java.util.Optional<java.lang.String> get​(java.lang.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 - the key to look up; never null or blank
        Returns:
        an Optional containing the value; never null but potentially empty
        See Also:
        getBoolean(String), System.getProperty(String), CONFIG_FILE_NAME
      • getBoolean

        java.util.Optional<java.lang.Boolean> getBoolean​(java.lang.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 - the key to look up; never null or blank
        Returns:
        an Optional containing the value; never null but potentially empty
        See Also:
        get(String), Boolean.parseBoolean(String), System.getProperty(String), CONFIG_FILE_NAME
      • get

        @API(status=STABLE,
             since="1.3")
        default <T> java.util.Optional<T> get​(java.lang.String key,
                                              java.util.function.Function<java.lang.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 - the key to look up; never null or blank
        transformer - the transformer to apply in case a value is found; never null
        Returns:
        an Optional containing the value; never null but potentially empty
        Since:
        1.3
        See Also:
        getBoolean(String), System.getProperty(String), CONFIG_FILE_NAME
      • size

        @Deprecated
        @API(status=DEPRECATED,
             since="1.9")
        int size()
        Deprecated.
        as of JUnit Platform 1.9 in favor of keySet()
        Get the number of configuration parameters stored directly in this ConfigurationParameters.
      • keySet

        @API(status=STABLE,
             since="1.9")
        java.util.Set<java.lang.String> keySet()
        Get the keys of all configuration parameters stored in this ConfigurationParameters.
        Returns:
        the set of keys contained in this ConfigurationParameters