Annotation Interface SetSystemProperty


@Retention(RUNTIME) @Target({METHOD,TYPE}) @Inherited @Repeatable(SetSystemProperty.SetSystemProperties.class) @ExtendWith(org.junit.jupiter.api.util.SystemPropertiesExtension.class) @API(status=EXPERIMENTAL, since="6.1") public @interface SetSystemProperty
@SetSystemProperty is an annotation that is used to set the value of a JVM system property for test execution.

The key and value of the system property must be specified via the key and value attributes.

This annotation can be used both at the type level and the method level. It is repeatable and @Inherited from higher-level containers — for example, a test method inherits a @SetSystemProperty declaration from the test class in which the test is declared. If this annotation is declared on a test class (or implemented interface), the configured property will be set before every test inside that class. After a test has completed, the original value of the system property (or the value configured via @SetSystemProperty at a higher level) will be restored. Note that method-level configuration always overrides class-level configuration.

During parallel test execution, all tests annotated with @SetSystemProperty, @ClearSystemProperty, @ReadsSystemProperty, and @WritesSystemProperty are scheduled in a way that guarantees correctness under mutation of shared global state.

For further details and examples, see the documentation on all JVM system property annotations in the User Guide.

Since:
6.1
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    @SetSystemProperties is a container for one or more SetSystemProperty declarations.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The key of the system property to set.
    The value of the system property to set.
  • Element Details

    • key

      String key
      The key of the system property to set.
    • value

      String value
      The value of the system property to set.