Search in sources :

Example 1 with TestExtensionContext

use of org.junit.jupiter.api.extension.TestExtensionContext in project spring-framework by spring-projects.

the class DisabledIfConditionTestCase method buildExtensionContext.

// -------------------------------------------------------------------------
private TestExtensionContext buildExtensionContext(String methodName) {
    Class<?> testClass = SpringTestCase.class;
    Method method = ReflectionUtils.findMethod(getClass(), methodName);
    Store store = mock(Store.class);
    when(store.getOrComputeIfAbsent(any(), any(), any())).thenReturn(new TestContextManager(testClass));
    TestExtensionContext extensionContext = mock(TestExtensionContext.class);
    when(extensionContext.getTestClass()).thenReturn(Optional.of(testClass));
    when(extensionContext.getElement()).thenReturn(Optional.of(method));
    when(extensionContext.getStore(any())).thenReturn(store);
    return extensionContext;
}
Also used : Store(org.junit.jupiter.api.extension.ExtensionContext.Store) Method(java.lang.reflect.Method) TestContextManager(org.springframework.test.context.TestContextManager) TestExtensionContext(org.junit.jupiter.api.extension.TestExtensionContext)

Aggregations

Method (java.lang.reflect.Method)1 Store (org.junit.jupiter.api.extension.ExtensionContext.Store)1 TestExtensionContext (org.junit.jupiter.api.extension.TestExtensionContext)1 TestContextManager (org.springframework.test.context.TestContextManager)1