Skip to content

Commit d3ec0fe

Browse files
committed
Disable TimeoutInvocationFactoryTests in Eclipse IDE
The default Mockito MockMaker (inline mock maker) fails to create a spy for NamespaceAwareStore when running within Eclipse IDE. - org.mockito.exceptions.base.MockitoException: Unable to initialize @⁠Spy annotated field 'store'. - Mockito cannot mock this class: class org.junit.jupiter.engine.execution.NamespaceAwareStore. - You are seeing this disclaimer because Mockito is configured to create inlined mocks. - Byte Buddy could not instrument all classes within the mock's type hierarchy. To address that, this commit disables TimeoutInvocationFactoryTests when running in Eclipse IDE.
1 parent 35d3dd7 commit d3ec0fe

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.junit.jupiter.api.DisplayName;
1919
import org.junit.jupiter.api.Test;
2020
import org.junit.jupiter.api.Timeout.ThreadMode;
21+
import org.junit.jupiter.api.condition.DisabledIf;
2122
import org.junit.jupiter.api.extension.ExtendWith;
2223
import org.junit.jupiter.api.extension.ExtensionContext;
2324
import org.junit.jupiter.api.extension.ExtensionContext.Store;
@@ -30,18 +31,27 @@
3031
import org.mockito.Spy;
3132
import org.mockito.junit.jupiter.MockitoExtension;
3233

34+
// org.mockito.exceptions.base.MockitoException: Unable to initialize @Spy annotated field 'store'.
35+
// Mockito cannot mock this class: class org.junit.jupiter.engine.execution.NamespaceAwareStore.
36+
// You are seeing this disclaimer because Mockito is configured to create inlined mocks.
37+
// 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")
3339
@DisplayName("TimeoutInvocationFactory")
3440
@ExtendWith(MockitoExtension.class)
3541
class TimeoutInvocationFactoryTests {
3642

3743
@Spy
3844
private final Store store = new NamespaceAwareStore(new NamespacedHierarchicalStore<>(null),
3945
ExtensionContext.Namespace.create(TimeoutInvocationFactoryTests.class));
46+
4047
@Mock
4148
private Invocation<String> invocation;
49+
4250
@Mock
4351
private TimeoutDuration timeoutDuration;
52+
4453
private TimeoutInvocationFactory timeoutInvocationFactory;
54+
4555
private TimeoutInvocationParameters<String> parameters;
4656

4757
@BeforeEach
@@ -86,4 +96,13 @@ void shouldCreateTimeoutInvocationForSeparateThreadTimeoutThreadMode() {
8696
assertThat(invocation).isInstanceOf(SeparateThreadTimeoutInvocation.class);
8797
}
8898

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

0 commit comments

Comments
 (0)