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.
- Since:
- 1.0
- See Also:
-
Nested Class Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
TestPlan
(boolean containsTests, ConfigurationParameters configurationParameters) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(TestPlan.Visitor visitor) Accept the suppliedTestPlan.Visitor
for a depth-first traversal of the test plan.void
add
(TestIdentifier testIdentifier) Deprecated.Calling this method is no longer supported and will throw an exception.void
addInternal
(TestIdentifier testIdentifier) boolean
Return whether this test plan contains any tests.long
countTestIdentifiers
(Predicate<? super TestIdentifier> predicate) Count allTestIdentifiers
that satisfy the given predicate.static TestPlan
from
(Collection<TestDescriptor> engineDescriptors, ConfigurationParameters configurationParameters) Construct a newTestPlan
from the supplied collection ofTestDescriptors
.getChildren
(String parentId) Deprecated.getChildren
(UniqueId parentId) Get the children of the supplied unique ID.getChildren
(TestIdentifier parent) Get the children of the suppliedTestIdentifier
.Get theConfigurationParameters
for this test plan.getDescendants
(TestIdentifier parent) Get all descendants of the suppliedTestIdentifier
(i.e., all of its children and their children, recursively).getParent
(TestIdentifier child) Get the parent of the suppliedTestIdentifier
.getRoots()
Get the rootTestIdentifiers
for this test plan.getTestIdentifier
(String uniqueId) Deprecated.getTestIdentifier
(UniqueId uniqueId) Get theTestIdentifier
with the supplied unique ID.
-
Constructor Details
-
TestPlan
@API(status=INTERNAL, since="1.4") protected TestPlan(boolean containsTests, ConfigurationParameters configurationParameters)
-
-
Method Details
-
from
@API(status=INTERNAL, since="1.0") public static TestPlan from(Collection<TestDescriptor> engineDescriptors, ConfigurationParameters configurationParameters) Construct a newTestPlan
from the supplied collection ofTestDescriptors
.Each supplied
TestDescriptor
is expected to be a descriptor for aTestEngine
.- Parameters:
engineDescriptors
- the engine test descriptors from which the test plan should be created; nevernull
configurationParameters
- theConfigurationParameters
for this test plan; nevernull
- Returns:
- a new test plan
-
add
Deprecated.Calling this method is no longer supported and will throw an exception.Add the suppliedTestIdentifier
to this test plan.- Parameters:
testIdentifier
- the identifier to add; nevernull
- Throws:
JUnitException
- always
-
addInternal
-
getRoots
Get the rootTestIdentifiers
for this test plan.- Returns:
- an unmodifiable set of the root identifiers
-
getParent
Get the parent of the suppliedTestIdentifier
.- Parameters:
child
- the identifier to look up the parent for; nevernull
- Returns:
- an
Optional
containing the parent, if present
-
getChildren
Get the children of the suppliedTestIdentifier
.- Parameters:
parent
- the identifier to look up the children for; nevernull
- Returns:
- an unmodifiable set of the parent's children, potentially empty
- See Also:
-
getChildren
@API(status=DEPRECATED, since="1.10") @Deprecated public Set<TestIdentifier> getChildren(String parentId) Deprecated.Get the children of the supplied unique ID.- Parameters:
parentId
- the unique ID to look up the children for; nevernull
or blank- Returns:
- an unmodifiable set of the parent's children, potentially empty
- See Also:
-
getChildren
Get the children of the supplied unique ID.- Parameters:
parentId
- the unique ID to look up the children for; nevernull
- Returns:
- an unmodifiable set of the parent's children, potentially empty
- See Also:
-
getTestIdentifier
@API(status=DEPRECATED, since="1.10") @Deprecated public TestIdentifier getTestIdentifier(String uniqueId) throws PreconditionViolationException Deprecated.Get theTestIdentifier
with the supplied unique ID.- Parameters:
uniqueId
- the unique ID to look up the identifier for; nevernull
or blank- Returns:
- the identifier with the supplied unique ID; never
null
- Throws:
PreconditionViolationException
- if noTestIdentifier
with the supplied unique ID is present in this test plan
-
getTestIdentifier
Get theTestIdentifier
with the supplied unique ID.- Parameters:
uniqueId
- the unique ID to look up the identifier for; nevernull
- Returns:
- the identifier with the supplied unique ID; never
null
- Throws:
PreconditionViolationException
- if noTestIdentifier
with the supplied unique ID is present in this test plan
-
countTestIdentifiers
Count allTestIdentifiers
that satisfy the given predicate.- Parameters:
predicate
- a predicate which returnstrue
for identifiers to be counted; nevernull
- Returns:
- the number of identifiers that satisfy the supplied predicate
-
getDescendants
Get all descendants of the suppliedTestIdentifier
(i.e., all of its children and their children, recursively).- Parameters:
parent
- the identifier to look up the descendants for; nevernull
- Returns:
- an unmodifiable set of the parent's descendants, potentially empty
-
containsTests
public boolean containsTests()Return whether this test plan contains any tests.A test plan contains tests, if at least one of the contained engine descriptors contains tests.
- Returns:
true
if this test plan contains tests- See Also:
-
getConfigurationParameters
Get theConfigurationParameters
for this test plan.- Returns:
- the configuration parameters; never
null
- Since:
- 1.8
-
accept
Accept the suppliedTestPlan.Visitor
for a depth-first traversal of the test plan.- Parameters:
visitor
- the visitor to accept; nevernull
- Since:
- 1.10
-