Skip to content

Commit 532ff36

Browse files
authored
Fix flaky test by isolating tests that modify user.home (#6574)
MavenSecuritySettingsTest and MavenSettingsTest modify the global user.home system property during tests. With parallel test execution enabled, other tests could pick up the modified property pointing to an empty temp directory, causing parse failures. Added @isolated annotation to ensure these tests run alone.
1 parent 93642f6 commit 532ff36

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

rewrite-maven/src/test/java/org/openrewrite/maven/MavenSecuritySettingsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.junit.jupiter.api.io.TempDir;
2222
import org.junit.jupiter.api.parallel.Execution;
2323
import org.junit.jupiter.api.parallel.ExecutionMode;
24+
import org.junit.jupiter.api.parallel.Isolated;
2425
import org.openrewrite.InMemoryExecutionContext;
2526

2627
import java.io.IOException;
@@ -29,6 +30,7 @@
2930

3031
import static org.assertj.core.api.Assertions.assertThat;
3132

33+
@Isolated("Modifies user.home system property")
3234
@Execution(ExecutionMode.SAME_THREAD)
3335
class MavenSecuritySettingsTest {
3436

rewrite-maven/src/test/java/org/openrewrite/maven/MavenSettingsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.junit.jupiter.api.io.TempDir;
2929
import org.junit.jupiter.api.parallel.Execution;
3030
import org.junit.jupiter.api.parallel.ExecutionMode;
31+
import org.junit.jupiter.api.parallel.Isolated;
3132
import org.openrewrite.InMemoryExecutionContext;
3233
import org.openrewrite.Issue;
3334
import org.openrewrite.Parser;
@@ -49,6 +50,7 @@
4950
import static org.assertj.core.api.Assertions.assertThat;
5051

5152
@SuppressWarnings({"HttpUrlsUsage", "ConstantConditions", "OptionalGetWithoutIsPresent"})
53+
@Isolated("Modifies user.home system property")
5254
@Execution(ExecutionMode.SAME_THREAD)
5355
class MavenSettingsTest {
5456

0 commit comments

Comments
 (0)