42
42
import org .assertj .core .api .Condition ;
43
43
import org .junit .AssumptionViolatedException ;
44
44
import org .junit .jupiter .api .Test ;
45
+ import org .junit .jupiter .api .condition .DisabledIf ;
46
+ import org .junit .platform .commons .util .ReflectionUtils ;
45
47
import org .junit .platform .engine .EngineExecutionListener ;
46
48
import org .junit .platform .engine .ExecutionRequest ;
47
49
import org .junit .platform .engine .TestDescriptor ;
98
100
import org .junit .vintage .engine .samples .junit4 .PlainJUnit4TestCaseWithSingleTestWhichFails ;
99
101
import org .junit .vintage .engine .samples .junit4 .PlainJUnit4TestCaseWithSingleTestWhichIsIgnored ;
100
102
import org .junit .vintage .engine .samples .junit4 .PlainJUnit4TestCaseWithTwoTestMethods ;
101
- import org .junit .vintage .engine .samples .spock .SpockTestCaseWithUnrolledAndRegularFeatureMethods ;
102
103
import org .opentest4j .MultipleFailuresError ;
103
104
104
105
/**
@@ -862,13 +863,16 @@ void executesJUnit4TestCaseWithRunnerWithDuplicateChangingChildDescriptions() {
862
863
}
863
864
864
865
@ Test
866
+ @ DisabledIf ("runningInEclipse" )
865
867
void executesUnrolledSpockFeatureMethod () {
866
- Class <?> testClass = SpockTestCaseWithUnrolledAndRegularFeatureMethods .class ;
868
+ // Load Groovy class via reflection to avoid compilation errors in Eclipse IDE.
869
+ String testClassName = "org.junit.vintage.engine.samples.spock.SpockTestCaseWithUnrolledAndRegularFeatureMethods" ;
870
+ Class <?> testClass = ReflectionUtils .loadRequiredClass (testClassName , getClass ().getClassLoader ());
867
871
var request = LauncherDiscoveryRequestBuilder .request ().selectors (
868
872
selectMethod (testClass , "unrolled feature for #input" )).build ();
869
873
execute (request ).allEvents ().assertEventsMatchExactly ( //
870
874
event (engine (), started ()), //
871
- event (uniqueIdSubstring (testClass . getName () ), started ()), //
875
+ event (uniqueIdSubstring (testClassName ), started ()), //
872
876
event (dynamicTestRegistered ("unrolled feature for 23" )), //
873
877
event (test ("unrolled feature for 23" ), started ()), //
874
878
event (test ("unrolled feature for 23" ), finishedWithFailure ()), //
@@ -880,8 +884,11 @@ void executesUnrolledSpockFeatureMethod() {
880
884
}
881
885
882
886
@ Test
887
+ @ DisabledIf ("runningInEclipse" )
883
888
void executesRegularSpockFeatureMethod () {
884
- Class <?> testClass = SpockTestCaseWithUnrolledAndRegularFeatureMethods .class ;
889
+ // Load Groovy class via reflection to avoid compilation errors in Eclipse IDE.
890
+ String testClassName = "org.junit.vintage.engine.samples.spock.SpockTestCaseWithUnrolledAndRegularFeatureMethods" ;
891
+ Class <?> testClass = ReflectionUtils .loadRequiredClass (testClassName , getClass ().getClassLoader ());
885
892
var request = LauncherDiscoveryRequestBuilder .request ().selectors (selectMethod (testClass , "regular" )).build ();
886
893
execute (request ).allEvents ().assertEventsMatchExactly ( //
887
894
event (engine (), started ()), //
@@ -938,4 +945,12 @@ private static boolean atLeastJUnit4_13() {
938
945
return JUnit4VersionCheck .parseVersion (Version .id ()).compareTo (new BigDecimal ("4.13" )) >= 0 ;
939
946
}
940
947
948
+ /**
949
+ * Determine if the current code is running in the Eclipse IDE.
950
+ */
951
+ static boolean runningInEclipse () {
952
+ return StackWalker .getInstance ().walk (
953
+ stream -> stream .anyMatch (stackFrame -> stackFrame .getClassName ().startsWith ("org.eclipse.jdt" )));
954
+ }
955
+
941
956
}
0 commit comments