Search in sources :

Example 1 with AbstractTestModule

use of core.framework.test.module.AbstractTestModule in project core-ng-project by neowu.

the class IntegrationExtension method createTestBeanFactory.

private TestBeanFactory createTestBeanFactory(Class<?> testClass, ExtensionContext.Store store) {
    Boolean initialized = store.get(KEY_INITIALIZED, Boolean.class);
    if (Boolean.TRUE.equals(initialized))
        throw new Error("test context failed to initialize, please check error message from previous integration test");
    store.put(KEY_INITIALIZED, true);
    Context context = findContext(testClass);
    TestBeanFactory beanFactory = new TestBeanFactory();
    try {
        AbstractTestModule module = context.module().getConstructor().newInstance();
        module.configure(beanFactory);
    } catch (ReflectiveOperationException e) {
        throw new Error("failed to create test context", e);
    }
    return beanFactory;
}
Also used : ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) AbstractTestModule(core.framework.test.module.AbstractTestModule) TestBeanFactory(core.framework.test.inject.TestBeanFactory)

Aggregations

TestBeanFactory (core.framework.test.inject.TestBeanFactory)1 AbstractTestModule (core.framework.test.module.AbstractTestModule)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1