Package com.oracle.bedrock.junit
Class SystemPropertyExtension
java.lang.Object
com.oracle.bedrock.junit.SystemPropertyExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.Extension
public class SystemPropertyExtension
extends Object
implements org.junit.jupiter.api.extension.BeforeAllCallback
A JUnit 5 extension that sets System properties in the
before all phase.
By using this extension with @Order
after other extensions, it is possible to configures properties based on
the state of other extensions before tests run.
- Since:
- 22.06
- Author:
- Jonathan Knight 2022.06.20
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) withProperty(String key, Supplier<?> value) Add a property to set.
-
Constructor Details
-
SystemPropertyExtension
public SystemPropertyExtension()
-
-
Method Details
-
beforeAll
- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
withProperty
Add a property to set.The
toString()of the value returned by the supplier will be used as the property value.If the
Supplierreturnsnullthen no property will be set.- Parameters:
key- the key of the propertyvalue- a supplier for the property value- Returns:
- this builder
-