Class PreserveSystemPropertyRule
java.lang.Object
com.atlassian.bamboo.testutils.junit.rule.PreserveSystemPropertyRule
- All Implemented Interfaces:
org.junit.rules.TestRule
Rule which ensures tests that modify system properties doesn't interfere (eg. by concurrently modifying the properties).
Additionally it will save modified properties before and restore them after running a test.
There are tree ways to mark which tests will modify which properties:
- passing list of properties name to the constructor. Then those properties will be preserved for each test in a test class
- annotating test method with {@link @com.atlassian.bamboo.testutils.junit.rule.PreserveSystemProperties}
- calling PreserveSystemPropertyRule#preserveProperties(SystemProperty... properties)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) void
preserveProperties
(AbstractSystemProperty... properties)
-
Constructor Details
-
PreserveSystemPropertyRule
public PreserveSystemPropertyRule() -
PreserveSystemPropertyRule
- Parameters:
testClassProperties
- names of System properties to preserve and restore for every test in a test class
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
preserveProperties
-