Details
Recommendation type: System properties changed
Configurable in Preferences: Yes
Filter category: Unstable test environment
Description
Tests should not have side effects on their test environment. Failing to reset modified Java system properties can cause other tests to fail. Modified Java system properties should be restored by the time the test has completed.
Example
In the following example, the system properties are restored after the test is executed. Failing to restore the properties will generate this recommendation.
public class MyTest { @Before public void setUp() { // prepare environment for test System.setProperty("my.property", "myvalue"); } @After public void tearDown() { // restore original environment System.setProperty("myproperty", null); } }