use of org.junit.jupiter.api.extension.ExtensionContext.Store 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;
}
use of org.junit.jupiter.api.extension.ExtensionContext.Store in project spring-framework by spring-projects.
the class SpringExtension method getTestContextManager.
/**
* Get the {@link TestContextManager} associated with the supplied {@code ExtensionContext}.
* @return the {@code TestContextManager} (never {@code null})
*/
private static TestContextManager getTestContextManager(ExtensionContext context) {
Assert.notNull(context, "ExtensionContext must not be null");
Class<?> testClass = context.getTestClass().get();
Store store = context.getStore(NAMESPACE);
return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class);
}
Aggregations