{"id":"603a4a7b21295562","repo":"junit-team/junit5","slug":"error-executing-tests-for-engine-getid","errorCode":null,"errorMessage":"Error executing tests for engine ${getId()}","messagePattern":"Error executing tests for engine (.+?)","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"critical","filePath":"junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/HierarchicalTestEngine.java","lineNumber":70,"sourceCode":"\t *\n\t * <p>Supports cancellation via the {@link CancellationToken} passed in the\n\t * supplied {@code request}.\n\t *\n\t * @see Node\n\t * @see #createExecutorService\n\t * @see #createExecutionContext\n\t * @see #createThrowableCollectorFactory\n\t */\n\t@Override\n\tpublic final void execute(ExecutionRequest request) {\n\t\ttry (HierarchicalTestExecutorService executorService = createExecutorService(request)) {\n\t\t\tC executionContext = createExecutionContext(request);\n\t\t\tThrowableCollector.Factory throwableCollectorFactory = createThrowableCollectorFactory(request);\n\t\t\tnew HierarchicalTestExecutor<>(request, executionContext, executorService,\n\t\t\t\tthrowableCollectorFactory).execute().get();\n\t\t}\n\t\tcatch (Exception exception) {\n\t\t\tthrow new JUnitException(\"Error executing tests for engine \" + getId(), exception);\n\t\t}\n\t}\n\n\t/**\n\t * Create the {@linkplain HierarchicalTestExecutorService executor service}\n\t * to use for executing the supplied {@linkplain ExecutionRequest request}.\n\t *\n\t * <p>An engine may use the information in the supplied <em>request</em>\n\t * such as the contained\n\t * {@linkplain ExecutionRequest#getConfigurationParameters() configuration parameters}\n\t * to decide what kind of service to return or how to configure it.\n\t *\n\t * <p>By default, this method returns an instance of\n\t * {@link SameThreadHierarchicalTestExecutorService}.\n\t *\n\t * @param request the request about to be executed\n\t * @since 1.3\n\t * @see ForkJoinPoolHierarchicalTestExecutorService","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/HierarchicalTestEngine.java#L52-L88","documentation":"Thrown by HierarchicalTestEngine.execute (line 62-72) as a catch-all JUnitException wrapping any Exception that escapes the try-with-resources block around the executor service, execution context, and the HierarchicalTestExecutor.execute().get() call. It names the engine via getId() so the caller knows which engine failed.","triggerScenarios":"Any uncaught Exception during execution setup/teardown: createExecutorService throws, createExecutionContext throws, the executor's Future.get() throws (ExecutionException wrapping a test/extension error), or close() on the executor service throws. Test-level assertion failures are normally collected by ThrowableCollector and do not surface here.","commonSituations":"A broken @RegisterExtension or @TestInstance factory throwing during context creation; parallel executor misconfiguration (see error 113) surfacing through execute(); a custom HierarchicalTestEngine whose createExecutionContext throws; interrupted execution where the executor future fails.","solutions":["Inspect the caused-by exception; it is the real failure. Fix that root cause.","If the cause is an ExecutionException, unwrap one more level to reach the actual test/extension error.","Verify createExecutorService / createExecutionContext implementations for custom engines do not throw for valid requests.","Check for parallel-execution configuration issues if ForkJoinPool/WorkerThreadPool creation is in the stack."],"exampleFix":"// before: custom engine context throws\n@Override protected EngineExecutionContext createExecutionContext(ExecutionRequest r) {\n    return contextFactory.build(); // throws -> wraps as 'Error executing tests for engine ...'\n}\n\n// after: defensive construction with clear error\n@Override protected EngineExecutionContext createExecutionContext(ExecutionRequest r) {\n    try { return contextFactory.build(); }\n    catch (IllegalStateException e) {\n        throw new JUnitException(\"Could not build execution context\", e);\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    engine.execute(request);\n} catch (JUnitException e) {\n    Throwable cause = e.getCause();\n    // cause is the real failure (often ExecutionException with another cause)\n    log.error(\"engine {} failed\", engine.getId(), cause);\n    throw cause != null ? cause : e;\n}","preventionTips":["Always unwrap the caused-by exception; the JUnitException is a wrapper.","Test createExecutorService/createExecutionContext for custom engines with valid inputs.","Validate parallel-execution config before engine execution."],"tags":["junit-platform","hierarchical-test-engine","execution","engine","wrapper-exception"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}