junit-team/junit5 · critical · JUnitException

Error executing tests for engine

Error message

Error executing tests for engine ${getId()}

What it means

The top-level catch in HierarchicalTestEngine.execute(ExecutionRequest): any Exception escaping the executor service lifecycle, context creation, throwable-collector factory, or the executor's Future.get() is rethrown as a JUnitException with the offending engine id. It is an umbrella error: the real failure is always in the chained cause.

Solutions

  1. Read the chained cause (exception.getCause()) - it is the actual failure; fix that root cause first.
  2. If the cause is a ForkJoinPool/parallel-execution failure, see error 121 fixes (check junit.execution.parallel.config.* properties).
  3. If the cause is InterruptedException, ensure the launching thread is not interrupted and no external timeout is aborting execution.
  4. If using a custom HierarchicalTestEngine, verify createExecutionContext/createExecutorService/createThrowableCollectorFactory do not throw on valid requests.

Example fix

// before
try {
    engine.execute(request);
} catch (JUnitException e) {
    log.error(e.getMessage()); // only sees the umbrella message
}
// after
try {
    engine.execute(request);
} catch (JUnitException e) {
    Throwable root = e.getCause() != null ? e.getCause() : e;
    log.error("Engine {} failed: {}", engine.getId(), root, root);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    engine.execute(request);
} catch (JUnitException e) {
    Throwable root = (e.getCause() instanceof ExecutionException ee) ? ee.getCause() : e.getCause();
    // branch on root type: config error, OOM, interrupted, etc.
    throw root != null ? new RuntimeException(root) : e;
}

Prevention

When it happens

Trigger: createExecutorService(request) throws (e.g. error 121), createExecutionContext(request) throws, createThrowableCollectorFactory(request) throws, or HierarchicalTestExecutor.execute().get() throws an ExecutionException wrapping an internal engine failure (interrupted, OOM, lock acquisition failure, etc.).

Common situations: Misconfigured parallel execution causing pool creation failure; a custom HierarchicalTestEngine whose context factory throws; thread interruption during execution; an ExclusiveResource lock that deadlocks/times out; OOM during a large test graph; SPI or classpath issues loading engine internals.

Related errors


AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11). Data as JSON: /api/errors/603a4a7b21295562. Report an issue: GitHub.

Appendix: source

Thrown at junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/HierarchicalTestEngine.java:70

	 *
	 * <p>Supports cancellation via the {@link CancellationToken} passed in the
	 * supplied {@code request}.
	 *
	 * @see Node
	 * @see #createExecutorService
	 * @see #createExecutionContext
	 * @see #createThrowableCollectorFactory
	 */
	@Override
	public final void execute(ExecutionRequest request) {
		try (HierarchicalTestExecutorService executorService = createExecutorService(request)) {
			C executionContext = createExecutionContext(request);
			ThrowableCollector.Factory throwableCollectorFactory = createThrowableCollectorFactory(request);
			new HierarchicalTestExecutor<>(request, executionContext, executorService,
				throwableCollectorFactory).execute().get();
		}
		catch (Exception exception) {
			throw new JUnitException("Error executing tests for engine " + getId(), exception);
		}
	}

	/**
	 * Create the {@linkplain HierarchicalTestExecutorService executor service}
	 * to use for executing the supplied {@linkplain ExecutionRequest request}.
	 *
	 * <p>An engine may use the information in the supplied <em>request</em>
	 * such as the contained
	 * {@linkplain ExecutionRequest#getConfigurationParameters() configuration parameters}
	 * to decide what kind of service to return or how to configure it.
	 *
	 * <p>By default, this method returns an instance of
	 * {@link SameThreadHierarchicalTestExecutorService}.
	 *
	 * @param request the request about to be executed
	 * @since 1.3
	 * @see ForkJoinPoolHierarchicalTestExecutorService

View on GitHub (pinned to f070c699a0)