Debian Codegraph @

junit-platform-engine/src/main/java/org/junit/platform/engine/ExecutionRequest.java

raw
1 /*
2 * Copyright 2015-2024 the original author or authors.
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v2.0 which
6 * accompanies this distribution and is available at
7 *
8 * https://www.eclipse.org/legal/epl-v20.html
9 */
10
11 package org.junit.platform.engine;
12
13 import static org.apiguardian.api.API.Status.INTERNAL;
14 import static org.apiguardian.api.API.Status.STABLE;
15
16 import org.apiguardian.api.API;
17
18 /**
19 * Provides a single {@link TestEngine} access to the information necessary to
20 * execute its tests.
21 *
22 * <p>A request contains an engine's root {@link TestDescriptor}, the
23 * {@link EngineExecutionListener} to be notified of test execution events, and
24 * {@link ConfigurationParameters} that the engine may use to influence test
25 * execution.
26 *
27 * @since 1.0
28 * @see TestEngine
29 */
30 @API(status = STABLE, since = "1.0")
31 public class ExecutionRequest {
32
33 private final TestDescriptor rootTestDescriptor;
34
35 private final EngineExecutionListener engineExecutionListener;
36
37 private final ConfigurationParameters configurationParameters;
38
39 @API(status = INTERNAL, since = "1.0")
40 public ExecutionRequest(TestDescriptor rootTestDescriptor, EngineExecutionListener engineExecutionListener,
41 ConfigurationParameters configurationParameters) {
42 this.rootTestDescriptor = rootTestDescriptor;
43 this.engineExecutionListener = engineExecutionListener;
44 this.configurationParameters = configurationParameters;
45 }
46
47 /**
48 * Factory for creating an execution request.
49 *
50 * @param rootTestDescriptor the engine's root {@link TestDescriptor}
51 * @param engineExecutionListener the {@link EngineExecutionListener} to be
52 * notified of test execution events
53 * @param configurationParameters {@link ConfigurationParameters} that the
54 * engine may use to influence test execution
55 * @return a new {@code ExecutionRequest}; never {@code null}
56 * @since 1.9
57 */
58 @API(status = STABLE, since = "1.9")
59 public static ExecutionRequest create(TestDescriptor rootTestDescriptor,
60 EngineExecutionListener engineExecutionListener, ConfigurationParameters configurationParameters) {
61 return new ExecutionRequest(rootTestDescriptor, engineExecutionListener, configurationParameters);
62 }
63
64 /**
65 * Get the root {@link TestDescriptor} of the engine that processes this
66 * request.
67 *
68 * <p><strong>Note</strong>: the <em>root</em> descriptor is the
69 * {@code TestDescriptor} returned by
70 * {@link TestEngine#discover(EngineDiscoveryRequest, UniqueId)}.
71 */
72 public TestDescriptor getRootTestDescriptor() {
73 return this.rootTestDescriptor;
74 }
75
76 /**
77 * Get the {@link EngineExecutionListener} to be notified of test execution
78 * events.
79 */
80 public EngineExecutionListener getEngineExecutionListener() {
81 return this.engineExecutionListener;
82 }
83
84 /**
85 * Get the {@link ConfigurationParameters} that the engine may use to
86 * influence test execution.
87 */
88 public ConfigurationParameters getConfigurationParameters() {
89 return this.configurationParameters;
90 }
91
92 }