use of org.junit.jupiter.engine.execution.ThrowableCollector in project junit5 by junit-team.
the class TestMethodTestDescriptor method execute.
@Override
public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext context, DynamicTestExecutor dynamicTestExecutor) throws Exception {
ThrowableCollector throwableCollector = context.getThrowableCollector();
// @formatter:off
invokeBeforeEachCallbacks(context);
if (throwableCollector.isEmpty()) {
invokeBeforeEachMethods(context);
if (throwableCollector.isEmpty()) {
invokeBeforeTestExecutionCallbacks(context);
if (throwableCollector.isEmpty()) {
invokeTestMethod(context, dynamicTestExecutor);
}
invokeAfterTestExecutionCallbacks(context);
}
invokeAfterEachMethods(context);
}
invokeAfterEachCallbacks(context);
// @formatter:on
throwableCollector.assertEmpty();
return context;
}
use of org.junit.jupiter.engine.execution.ThrowableCollector in project junit5 by junit-team.
the class TestMethodTestDescriptor method invokeBeforeMethodsOrCallbacksUntilExceptionOccurs.
private <T extends Extension> void invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(JupiterEngineExecutionContext context, BiFunction<ExtensionContext, T, Executable> generator, Class<T> type) {
ExtensionRegistry registry = context.getExtensionRegistry();
ExtensionContext extensionContext = context.getExtensionContext();
ThrowableCollector throwableCollector = context.getThrowableCollector();
for (T callback : registry.getExtensions(type)) {
Executable executable = generator.apply(extensionContext, callback);
throwableCollector.execute(executable);
if (throwableCollector.isNotEmpty()) {
break;
}
}
}
Aggregations