Restore original System Properties after tests

Many registry tools tests modify system properties but do not
restore them to original state. These tests must be isolated
from each other and cannot share the same test execution process.

This has a huge impact on test performance under Gradle, which
seems to have higher process startup overhead. Current Gradle
test config has to set 'forEvery' to 1, i.e., every test class
must be run in a freshly started process.

This change significantly reduces the number of tests that need
isolation, making it easier to optimize test config for the
remaining tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221350284
This commit is contained in:
weiminyu 2018-11-13 15:57:01 -08:00 committed by jianglai
parent 9fa2a84c35
commit 75add42a1b
11 changed files with 125 additions and 26 deletions

View file

@ -17,7 +17,9 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.Sets;
import google.registry.testing.SystemPropertyRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -26,9 +28,11 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class GtechToolTest {
@Rule public final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
@Before
public void init() {
RegistryToolEnvironment.UNITTEST.setup();
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
}
@Test