@API(value=Experimental) public final class TestPlan extends 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. |
boolean |
containsTests() |
long |
countTestIdentifiers(Predicate<? super TestIdentifier> predicate)
Count all
TestIdentifiers that satisfy the
given predicate. |
static TestPlan |
from(Collection<TestDescriptor> engineDescriptors)
Construct a new
TestPlan from the supplied collection of
TestDescriptors . |
Set<TestIdentifier> |
getChildren(String parentId)
Get the children of the supplied unique ID.
|
Set<TestIdentifier> |
getChildren(TestIdentifier parent)
Get the children of the supplied
TestIdentifier . |
Set<TestIdentifier> |
getDescendants(TestIdentifier parent)
Get all descendants of the supplied
TestIdentifier (i.e.,
all of its children and their children, recursively). |
Optional<TestIdentifier> |
getParent(TestIdentifier child)
Get the parent of the supplied
TestIdentifier . |
Set<TestIdentifier> |
getRoots()
Get the root
TestIdentifiers for this test plan. |
TestIdentifier |
getTestIdentifier(String uniqueId)
Get the
TestIdentifier with the supplied unique ID. |
@API(value=Internal) public static TestPlan from(Collection<TestDescriptor> engineDescriptors)
TestPlan
from the supplied collection of
TestDescriptors
.
Each supplied TestDescriptor
is expected to be a descriptor
for a TestEngine
.
engineDescriptors
- the engine test descriptors from which the test
plan should be created; never null
public void add(TestIdentifier testIdentifier)
TestIdentifier
to this test plan.testIdentifier
- the identifier to add; never null
public Set<TestIdentifier> getRoots()
TestIdentifiers
for this test plan.public Optional<TestIdentifier> getParent(TestIdentifier child)
TestIdentifier
.child
- the identifier to look up the parent for; never null
Optional
containing the parent, if presentpublic Set<TestIdentifier> getChildren(TestIdentifier parent)
TestIdentifier
.parent
- the identifier to look up the children for; never null
getChildren(String)
public Set<TestIdentifier> getChildren(String parentId)
parentId
- the unique ID to look up the children for; never
null
or blankgetChildren(TestIdentifier)
public TestIdentifier getTestIdentifier(String uniqueId) throws PreconditionViolationException
TestIdentifier
with the supplied unique ID.uniqueId
- the unique ID to look up the identifier for; never
null
or blanknull
PreconditionViolationException
- if no TestIdentifier
with the supplied unique ID is present in this test planpublic long countTestIdentifiers(Predicate<? super TestIdentifier> predicate)
TestIdentifiers
that satisfy the
given predicate.predicate
- a predicate which returns true
for identifiers
to be counted; never null
public 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; never null
public boolean containsTests()