Skip to content

Commit 5bd73cb

Browse files
committed
Disable ClasspathAlignmentCheckerTests.allRootPackagesAreChecked() in Eclipse
This commit also extracts the common runningInEclipse() method into a new IdeUtils test fixture.
1 parent 78a3534 commit 5bd73cb

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2015-2025 the original author or authors.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License v2.0 which
6+
* accompanies this distribution and is available at
7+
*
8+
* https://www.eclipse.org/legal/epl-v20.html
9+
*/
10+
11+
package org.junit.platform.commons.test;
12+
13+
/**
14+
* Collection of test utilities for IDEs.
15+
*/
16+
public class IdeUtils {
17+
18+
/**
19+
* Determine if the current code is running in the Eclipse IDE.
20+
* <p>Copied from {@code org.springframework.core.testfixture.ide.IdeUtils}.
21+
*/
22+
public static boolean runningInEclipse() {
23+
return StackWalker.getInstance().walk(
24+
stream -> stream.anyMatch(stackFrame -> stackFrame.getClassName().startsWith("org.eclipse.jdt")));
25+
}
26+
27+
}

junit-vintage-engine/junit-vintage-engine.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies {
2424
testImplementation(projects.junitPlatformLauncher)
2525
testImplementation(projects.junitPlatformSuiteEngine)
2626
testImplementation(projects.junitPlatformTestkit)
27+
testImplementation(testFixtures(projects.junitPlatformCommons))
2728
testImplementation(testFixtures(projects.junitJupiterApi))
2829
testImplementation(testFixtures(projects.junitPlatformLauncher))
2930
testImplementation(testFixtures(projects.junitPlatformReporting))

junit-vintage-engine/src/test/java/org/junit/vintage/engine/VintageTestEngineExecutionTests.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ void executesJUnit4TestCaseWithRunnerWithDuplicateChangingChildDescriptions() {
865865
}
866866

867867
@Test
868-
@DisabledIf("runningInEclipse")
868+
@DisabledIf("org.junit.platform.commons.test.IdeUtils#runningInEclipse()")
869869
void executesUnrolledSpockFeatureMethod() {
870870
// Load Groovy class via reflection to avoid compilation errors in Eclipse IDE.
871871
String testClassName = "org.junit.vintage.engine.samples.spock.SpockTestCaseWithUnrolledAndRegularFeatureMethods";
@@ -888,7 +888,7 @@ void executesUnrolledSpockFeatureMethod() {
888888
}
889889

890890
@Test
891-
@DisabledIf("runningInEclipse")
891+
@DisabledIf("org.junit.platform.commons.test.IdeUtils#runningInEclipse()")
892892
void executesRegularSpockFeatureMethod() {
893893
// Load Groovy class via reflection to avoid compilation errors in Eclipse IDE.
894894
String testClassName = "org.junit.vintage.engine.samples.spock.SpockTestCaseWithUnrolledAndRegularFeatureMethods";
@@ -957,12 +957,4 @@ private static boolean atLeastJUnit4_13() {
957957
return JUnit4VersionCheck.parseVersion(Version.id()).compareTo(new BigDecimal("4.13")) >= 0;
958958
}
959959

960-
/**
961-
* Determine if the current code is running in the Eclipse IDE.
962-
*/
963-
static boolean runningInEclipse() {
964-
return StackWalker.getInstance().walk(
965-
stream -> stream.anyMatch(stackFrame -> stackFrame.getClassName().startsWith("org.eclipse.jdt")));
966-
}
967-
968960
}

jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/TimeoutInvocationFactoryTests.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
// Mockito cannot mock this class: class org.junit.jupiter.engine.execution.NamespaceAwareStore.
3636
// You are seeing this disclaimer because Mockito is configured to create inlined mocks.
3737
// Byte Buddy could not instrument all classes within the mock's type hierarchy.
38-
@DisabledIf(value = "runningInEclipse", disabledReason = "Mockito cannot create a spy for NamespaceAwareStore using the inline MockMaker in Eclipse IDE")
38+
@DisabledIf(//
39+
value = "org.junit.platform.commons.test.IdeUtils#runningInEclipse()", //
40+
disabledReason = "Mockito cannot create a spy for NamespaceAwareStore using the inline MockMaker in Eclipse IDE")
3941
@DisplayName("TimeoutInvocationFactory")
4042
@ExtendWith(MockitoExtension.class)
4143
class TimeoutInvocationFactoryTests {
@@ -100,13 +102,4 @@ void shouldCreateTimeoutInvocationForSeparateThreadTimeoutThreadMode() {
100102
assertThat(invocation).isInstanceOf(SeparateThreadTimeoutInvocation.class);
101103
}
102104

103-
/**
104-
* Determine if the current code is running in the Eclipse IDE.
105-
* <p>Copied from {@code org.springframework.core.testfixture.ide.IdeUtils}.
106-
*/
107-
static boolean runningInEclipse() {
108-
return StackWalker.getInstance().walk(
109-
stream -> stream.anyMatch(stackFrame -> stackFrame.getClassName().startsWith("org.eclipse.jdt")));
110-
}
111-
112105
}

platform-tests/src/test/java/org/junit/platform/launcher/core/ClasspathAlignmentCheckerTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import org.jspecify.annotations.Nullable;
2727
import org.junit.jupiter.api.Test;
28+
import org.junit.jupiter.api.condition.DisabledIf;
2829

2930
class ClasspathAlignmentCheckerTests {
3031

@@ -59,6 +60,7 @@ void wrapsLinkageErrorForUnalignedClasspath() {
5960
}
6061

6162
@Test
63+
@DisabledIf("org.junit.platform.commons.test.IdeUtils#runningInEclipse()")
6264
void allRootPackagesAreChecked() {
6365
var allowedFileNames = Pattern.compile("junit-(?:platform|jupiter|vintage)-.+[\\d.]+(?:-SNAPSHOT)?\\.jar");
6466
var classGraph = new ClassGraph() //
@@ -83,4 +85,5 @@ void allRootPackagesAreChecked() {
8385
.allMatch(name -> foundPackages.stream().anyMatch(it -> it.startsWith(name)));
8486
}
8587
}
88+
8689
}

0 commit comments

Comments
 (0)