@API(value=Experimental)
public final class TestPlan
extends java.lang.Object
TestPlan describes the tree of tests and containers as discovered
by a Launcher.
Tests and containers are represented by TestIdentifier instances.
The complete set of identifiers comprises a tree-like structure. However,
each identifier only stores the unique ID of its parent. This class provides
a number of helpful methods to retrieve the
parent,
children, and
descendants of an identifier.
While the contained instances of TestIdentifier are immutable,
instances of this class contain mutable state. For example, when a dynamic
test is registered at runtime, it is added to the original test plan and
reported to TestExecutionListener implementations.
Launcher,
TestExecutionListener| Modifier and Type | Method and Description |
|---|---|
void |
add(TestIdentifier testIdentifier)
Add the supplied
TestIdentifier to this test plan. |
long |
countTestIdentifiers(java.util.function.Predicate<? super TestIdentifier> predicate)
Count all identifiers that satisfy the
given predicate.
|
static TestPlan |
from(java.util.Collection<org.junit.gen5.engine.TestDescriptor> engineDescriptors) |
java.util.Set<TestIdentifier> |
getChildren(TestId parentId)
Get the children of the supplied
TestId. |
java.util.Set<TestIdentifier> |
getChildren(TestIdentifier parent)
Get the children of supplied
TestIdentifier. |
java.util.Set<TestIdentifier> |
getDescendants(TestIdentifier parent)
Get all descendants of the supplied
TestIdentifier (i.e.,
all of its children and their children, recursively). |
java.util.Optional<TestIdentifier> |
getParent(TestIdentifier child)
Get the parent of supplied
TestIdentifier. |
java.util.Set<TestIdentifier> |
getRoots()
Get the root identifiers of this test plan.
|
TestIdentifier |
getTestIdentifier(TestId testId)
Get the
TestIdentifier with the specified TestId. |
public static TestPlan from(java.util.Collection<org.junit.gen5.engine.TestDescriptor> engineDescriptors)
public void add(TestIdentifier testIdentifier)
TestIdentifier to this test plan.testIdentifier - the identifier to addpublic java.util.Set<TestIdentifier> getRoots()
public java.util.Optional<TestIdentifier> getParent(TestIdentifier child)
TestIdentifier.child - the identifier to look up the parent forOptional containing the parent, if presentpublic java.util.Set<TestIdentifier> getChildren(TestIdentifier parent)
TestIdentifier.parent - the identifier to look up the children forgetChildren(TestId)public java.util.Set<TestIdentifier> getChildren(TestId parentId)
TestId.parentId - the ID to look up the children forgetChildren(TestIdentifier)public TestIdentifier getTestIdentifier(TestId testId) throws org.junit.gen5.commons.util.PreconditionViolationException
TestIdentifier with the specified TestId.testId - the unique ID to look up the identifier fororg.junit.gen5.commons.util.PreconditionViolationException - if no TestIdentifier
with the specified unique ID is present in this test planpublic long countTestIdentifiers(java.util.function.Predicate<? super TestIdentifier> predicate)
predicate - a predicate which returns true for identifiers
to be countedpublic java.util.Set<TestIdentifier> getDescendants(TestIdentifier parent)
TestIdentifier (i.e.,
all of its children and their children, recursively).parent - the identifier to look up the descendants for