Class SystemPropertiesExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.Extension
In order to provide the property values to be injected, you must provide either a Properties or
Map<String,String> object named "SYSTEM_PROPERTIES" on the test class as a static field.
Alternately, you may specify the field name containing your properties using the ApplyProperties annotation
on the test method.
Before each test method is executed, the configured properties will be injected into the System properties; however, the original values will be stored and replaced after the test method has finished.
NOTE: Due to the global nature of the System properties, the test methods under this extension are locked so that only one should run at a time - that being said, if you run into odd issues, try executing these tests in a single-threaded manner (and/or report a bug if you feel the functionality could be improved).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) static PropertiesasProperties(Map<String, String> map) A helper method that may be used to convert aMapto aPropertiesobject containing the same data.voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
-
Constructor Details
-
SystemPropertiesExtension
public SystemPropertiesExtension()
-
-
Method Details
-
beforeEach
- Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Throws:
Exception
-
afterEach
- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-
asProperties
A helper method that may be used to convert aMapto aPropertiesobject containing the same data.- Parameters:
map- the map of property data- Returns:
- a Properties object containing the map data
-