The
RestoreSystemProperties rule undoes changes of system
properties when the test finishes (whether it passes or fails).
Let's assume the system property
YourProperty has the
value
YourValue. Now run the test
public void YourTest {
@Rule
public final TestRule restoreSystemProperties = new RestoreSystemProperties();
@Test
public void overrideProperty() {
System.setProperty("YourProperty", "other value");
assertEquals("other value", System.getProperty("YourProperty"));
}
}
After running the test, the system property
YourProperty has
the value
YourValue again.