@API(status=STABLE,
since="1.0")
public 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.
This class is not intended to be extended by clients.
Launcher,
TestExecutionListener| Modifier and Type | Class and Description |
|---|---|
static interface |
TestPlan.Visitor
Visitor for
TestIdentifiers in a TestPlan. |
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<UniqueId,TestIdentifier> |
allIdentifiers |
private java.util.Map<UniqueId,java.util.Set<TestIdentifier>> |
children |
private ConfigurationParameters |
configurationParameters |
private boolean |
containsTests |
private java.util.Set<TestIdentifier> |
roots |
| Modifier | Constructor and Description |
|---|---|
protected |
TestPlan(boolean containsTests,
ConfigurationParameters configurationParameters) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(TestPlan.Visitor visitor)
Accept the supplied
TestPlan.Visitor for a depth-first traversal of the
test plan. |
private void |
accept(TestPlan.Visitor visitor,
TestIdentifier testIdentifier) |
void |
add(TestIdentifier testIdentifier)
Deprecated.
Calling this method is no longer supported and will throw an
exception.
|
void |
addInternal(TestIdentifier testIdentifier) |
boolean |
containsTests()
Return whether this test plan contains any tests.
|
long |
countTestIdentifiers(java.util.function.Predicate<? super TestIdentifier> predicate)
Count all
TestIdentifiers that satisfy the
given predicate. |
static TestPlan |
from(java.util.Collection<TestDescriptor> engineDescriptors,
ConfigurationParameters configurationParameters)
Construct a new
TestPlan from the supplied collection of
TestDescriptors. |
java.util.Set<TestIdentifier> |
getChildren(java.lang.String parentId)
Deprecated.
|
java.util.Set<TestIdentifier> |
getChildren(TestIdentifier parent)
Get the children of the supplied
TestIdentifier. |
java.util.Set<TestIdentifier> |
getChildren(UniqueId parentId)
Get the children of the supplied unique ID.
|
ConfigurationParameters |
getConfigurationParameters()
Get the
ConfigurationParameters for this test plan. |
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 the supplied
TestIdentifier. |
java.util.Set<TestIdentifier> |
getRoots()
Get the root
TestIdentifiers for this test plan. |
TestIdentifier |
getTestIdentifier(java.lang.String uniqueId)
Deprecated.
|
TestIdentifier |
getTestIdentifier(UniqueId uniqueId)
Get the
TestIdentifier with the supplied unique ID. |
private final java.util.Set<TestIdentifier> roots
private final java.util.Map<UniqueId,java.util.Set<TestIdentifier>> children
private final java.util.Map<UniqueId,TestIdentifier> allIdentifiers
private final boolean containsTests
private final ConfigurationParameters configurationParameters
@API(status=INTERNAL,
since="1.4")
protected TestPlan(boolean containsTests,
ConfigurationParameters configurationParameters)
@API(status=INTERNAL,
since="1.0")
public static TestPlan from(java.util.Collection<TestDescriptor> engineDescriptors,
ConfigurationParameters configurationParameters)
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 nullconfigurationParameters - the ConfigurationParameters for
this test plan; never null@Deprecated
@API(status=DEPRECATED,
since="1.4")
public void add(TestIdentifier testIdentifier)
TestIdentifier to this test plan.testIdentifier - the identifier to add; never nullJUnitException - always@API(status=INTERNAL,
since="1.8")
public void addInternal(TestIdentifier testIdentifier)
public java.util.Set<TestIdentifier> getRoots()
TestIdentifiers for this test plan.public java.util.Optional<TestIdentifier> getParent(TestIdentifier child)
TestIdentifier.child - the identifier to look up the parent for; never nullOptional containing the parent, if presentpublic java.util.Set<TestIdentifier> getChildren(TestIdentifier parent)
TestIdentifier.parent - the identifier to look up the children for; never nullgetChildren(UniqueId)@API(status=DEPRECATED,
since="1.10")
@Deprecated
public java.util.Set<TestIdentifier> getChildren(java.lang.String parentId)
getChildren(UniqueId)parentId - the unique ID to look up the children for; never
null or blankgetChildren(TestIdentifier)@API(status=MAINTAINED,
since="1.10")
public java.util.Set<TestIdentifier> getChildren(UniqueId parentId)
parentId - the unique ID to look up the children for; never
nullgetChildren(TestIdentifier)@API(status=DEPRECATED,
since="1.10")
@Deprecated
public TestIdentifier getTestIdentifier(java.lang.String uniqueId)
throws PreconditionViolationException
getTestIdentifier(UniqueId)TestIdentifier with the supplied unique ID.uniqueId - the unique ID to look up the identifier for; never
null or blanknullPreconditionViolationException - if no TestIdentifier
with the supplied unique ID is present in this test plan@API(status=MAINTAINED,
since="1.10")
public TestIdentifier getTestIdentifier(UniqueId uniqueId)
TestIdentifier with the supplied unique ID.uniqueId - the unique ID to look up the identifier for; never
nullnullPreconditionViolationException - if no TestIdentifier
with the supplied unique ID is present in this test planpublic long countTestIdentifiers(java.util.function.Predicate<? super TestIdentifier> predicate)
TestIdentifiers that satisfy the
given predicate.predicate - a predicate which returns true for identifiers
to be counted; never nullpublic 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; never nullpublic boolean containsTests()
A test plan contains tests, if at least one of the contained engine descriptors contains tests.
true if this test plan contains testsTestDescriptor.containsTests(TestDescriptor)@API(status=MAINTAINED,
since="1.8")
public ConfigurationParameters getConfigurationParameters()
ConfigurationParameters for this test plan.null@API(status=EXPERIMENTAL,
since="1.10")
public void accept(TestPlan.Visitor visitor)
TestPlan.Visitor for a depth-first traversal of the
test plan.visitor - the visitor to accept; never nullprivate void accept(TestPlan.Visitor visitor, TestIdentifier testIdentifier)