Skip to content

Commit 3adeb16

Browse files
Add TestTask::getTestDescriptor method (#4717)
Since a `TestTask` always corresponds to a specific test node, making its descriptor available for further analysis in custom test engines may be useful. Resolves #4711. --------- Co-authored-by: Marc Philipp <[email protected]>
1 parent 61894ae commit 3adeb16

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/HierarchicalTestExecutorService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
package org.junit.platform.engine.support.hierarchical;
1212

13+
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
1314
import static org.apiguardian.api.API.Status.STABLE;
1415

1516
import java.util.List;
@@ -18,6 +19,7 @@
1819
import org.apiguardian.api.API;
1920
import org.jspecify.annotations.Nullable;
2021
import org.junit.platform.engine.ExecutionRequest;
22+
import org.junit.platform.engine.TestDescriptor;
2123
import org.junit.platform.engine.support.hierarchical.Node.ExecutionMode;
2224

2325
/**
@@ -95,6 +97,17 @@ interface TestTask {
9597
*/
9698
ResourceLock getResourceLock();
9799

100+
/**
101+
* Get the {@linkplain TestDescriptor test descriptor} of this task.
102+
*
103+
* @throws UnsupportedOperationException if not supported for this TestTask implementation
104+
* @since 6.0
105+
*/
106+
@API(status = EXPERIMENTAL, since = "6.0")
107+
default TestDescriptor getTestDescriptor() {
108+
throw new UnsupportedOperationException();
109+
}
110+
98111
/**
99112
* Execute this task.
100113
*/

junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/NodeTestTask.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public ExecutionMode getExecutionMode() {
8686
.orElseGet(node::getExecutionMode);
8787
}
8888

89+
@Override
90+
public TestDescriptor getTestDescriptor() {
91+
return testDescriptor;
92+
}
93+
8994
@Override
9095
public String toString() {
9196
return "NodeTestTask [" + testDescriptor + "]";

0 commit comments

Comments
 (0)