Top Description Inners Methods
org.junit.platform.engine.support.hierarchical

public Interface Node<C extends EngineExecutionContext>

Annotations
@API
status:MAINTAINED
since:1.0
consumers:hierarchical
Type Parameters
<C>
the type of EngineExecutionContext used by the HierarchicalTestEngine
Static Imports
java.util.Collections.emptySet, org.apiguardian.api.API.Status.MAINTAINED, .API.Status.STABLE

A node within the execution hierarchy.
Since
1.0
See Also
HierarchicalTestEngine

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Node.DynamicTestExecutor

Executor for additional, dynamic test descriptors discovered during execution of a Node.

public static enum
Node.ExecutionMode

Supported execution modes for parallel execution.

public static interface
Node.Invocation<
the type of EngineExecutionContext used by the HierarchicalTestEngine
C extends EngineExecutionContext
>

Represents an invocation that runs with the supplied context.

public static class
Node.SkipResult

The result of determining whether the execution of a given context should be skipped.

Method Summary

Modifier and TypeMethod and Description
public default void
after(C
the context to execute in
context
)

Execute the after behavior of this node.

public default void
around(C
context the context to execute in
context
,
Node.Invocation<C>
the wrapped invocation (must be invoked exactly once)
invocation
)

Wraps around the invocation of before(EngineExecutionContext), execute(EngineExecutionContext, DynamicTestExecutor), and after(EngineExecutionContext).

public default C

Returns:

the new context to be used for children of this node; never null
before
(C
the context to execute in
context
)

Execute the before behavior of this node.

public default void
cleanUp(C
the context to execute in
context
)

Clean up the supplied context after execution.

public default C

Returns:

the new context to be used for children of this node and for the after behavior of the parent of this node, if any
execute
(C
the context to execute in
context
,
Node.DynamicTestExecutor
the executor to submit dynamic tests to
dynamicTestExecutor
)

Execute the behavior of this node.

public default Set<ExclusiveResource>

Returns:

the set of exclusive resources required by this node; never null but potentially empty
getExclusiveResources
()

Get the set of exclusive resources required to execute this node.

public default Node.ExecutionMode

Returns:

the preferred execution mode of this node; never null
getExecutionMode
()

Get the preferred of execution mode for parallel execution of this node.

public default void
nodeFinished(C
the execution context
context
,
TestDescriptor
the test descriptor that was executed
testDescriptor
,
TestExecutionResult
the result of the execution
result
)

Callback invoked when the execution of this node has finished.

public default void
nodeSkipped(C
the execution context
context
,
TestDescriptor
the test descriptor that was skipped
testDescriptor
,
Node.SkipResult
the result of skipped execution
result
)

Callback invoked when the execution of this node has been skipped.

public default C
prepare(C context)

Prepare the supplied context prior to execution.

public default Node.SkipResult
shouldBeSkipped(C context)

Determine if the execution of the supplied context should be skipped.

Method Detail

afterback to summary
public default void after(C context) throws Exception

Execute the after behavior of this node.

This method will be called once after execution of this node.

The default implementation does nothing.

Parameters
context:C

the context to execute in

See Also
before, execute
aroundback to summary
public default void around(C context, Node.Invocation<C> invocation) throws Exception

Wraps around the invocation of before(EngineExecutionContext), execute(EngineExecutionContext, DynamicTestExecutor), and after(EngineExecutionContext).

Parameters
context:C

context the context to execute in

invocation:Node.Invocation<C>

the wrapped invocation (must be invoked exactly once)

Annotations
@API
status:STABLE
since:1.10
Since
1.4
beforeback to summary
public default C before(C context) throws Exception

Execute the before behavior of this node.

This method will be called once before execution of this node.

The default implementation returns the supplied context unmodified.

Parameters
context:C

the context to execute in

Returns:C

the new context to be used for children of this node; never null

See Also
execute(EngineExecutionContext, DynamicTestExecutor), after(EngineExecutionContext)
cleanUpback to summary
public default void cleanUp(C context) throws Exception

Clean up the supplied context after execution.

The default implementation does nothing.

Parameters
context:C

the context to execute in

Since
1.1
See Also
prepare(EngineExecutionContext)
executeback to summary
public default C execute(C context, Node.DynamicTestExecutor dynamicTestExecutor) throws Exception

Execute the behavior of this node.

Containers typically do not implement this method since the HierarchicalTestEngine handles execution of their children.

The supplied dynamicTestExecutor may be used to submit additional dynamic tests for immediate execution.

The default implementation returns the supplied context unmodified.

Parameters
context:C

the context to execute in

dynamicTestExecutor:Node.DynamicTestExecutor

the executor to submit dynamic tests to

Returns:C

the new context to be used for children of this node and for the after behavior of the parent of this node, if any

See Also
before, after
getExclusiveResourcesback to summary
public default Set<ExclusiveResource> getExclusiveResources()

Get the set of exclusive resources required to execute this node.

The default implementation returns an empty set.

Returns:Set<ExclusiveResource>

the set of exclusive resources required by this node; never null but potentially empty

Annotations
@API
status:STABLE
since:1.10
consumers:hierarchical
Since
1.3
See Also
ExclusiveResource
getExecutionModeback to summary
public default Node.ExecutionMode getExecutionMode()

Get the preferred of execution mode for parallel execution of this node.

The default implementation returns ExecutionMode#CONCURRENT.

Returns:Node.ExecutionMode

the preferred execution mode of this node; never null

Annotations
@API
status:STABLE
since:1.10
consumers:hierarchical
Since
1.3
See Also
ExecutionMode
nodeFinishedback to summary
public default void nodeFinished(C context, TestDescriptor testDescriptor, TestExecutionResult result)

Callback invoked when the execution of this node has finished.

The default implementation does nothing.

Parameters
context:C

the execution context

testDescriptor:TestDescriptor

the test descriptor that was executed

result:TestExecutionResult

the result of the execution

Annotations
@API
status:STABLE
since:1.10
consumers:hierarchical
Since
1.4
nodeSkippedback to summary
public default void nodeSkipped(C context, TestDescriptor testDescriptor, Node.SkipResult result)

Callback invoked when the execution of this node has been skipped.

The default implementation does nothing.

Parameters
context:C

the execution context

testDescriptor:TestDescriptor

the test descriptor that was skipped

result:Node.SkipResult

the result of skipped execution

Annotations
@API
status:STABLE
since:1.10
consumers:hierarchical
Since
1.4
prepareback to summary
public default C prepare(C context) throws Exception

Prepare the supplied context prior to execution.

The default implementation returns the supplied context unmodified.

See Also
cleanUp(EngineExecutionContext)
shouldBeSkippedback to summary
public default Node.SkipResult shouldBeSkipped(C context) throws Exception

Determine if the execution of the supplied context should be skipped.

The default implementation returns SkipResult#doNotSkip().

org.junit.platform.engine.support.hierarchical back to summary

public Interface Node.DynamicTestExecutor

Known Direct Implementers
org.junit.platform.engine.support.hierarchical.NodeTestTask.DefaultDynamicTestExecutor

Executor for additional, dynamic test descriptors discovered during execution of a Node.

The test descriptors will be executed by the same HierarchicalTestExecutor that executes the submitting node.

This interface is not intended to be implemented by clients.

See Also
Node#execute(EngineExecutionContext, DynamicTestExecutor), HierarchicalTestExecutor

Method Summary

Modifier and TypeMethod and Description
public void
awaitFinished()

Block until all dynamic test descriptors submitted to this executor are finished.

public void
execute(TestDescriptor
the test descriptor to be executed; never null
testDescriptor
)

Submit a dynamic test descriptor for immediate execution.

public Future<?>

Returns:

a future to cancel or wait for the execution
execute
(TestDescriptor
the test descriptor to be executed; never null
testDescriptor
,
EngineExecutionListener
the executionListener to be notified; never null
executionListener
)

Submit a dynamic test descriptor for immediate execution with a custom, potentially no-op, execution listener.

Method Detail

awaitFinishedback to summary
public void awaitFinished() throws InterruptedException

Block until all dynamic test descriptors submitted to this executor are finished.

This method is useful if the node needs to perform actions in its execute(EngineExecutionContext, DynamicTestExecutor) method after all its dynamic children have finished.

Exceptions
InterruptedException:
if interrupted while waiting
executeback to summary
public void execute(TestDescriptor testDescriptor)

Submit a dynamic test descriptor for immediate execution.

Parameters
testDescriptor:TestDescriptor

the test descriptor to be executed; never null

executeback to summary
public Future<?> execute(TestDescriptor testDescriptor, EngineExecutionListener executionListener)

Submit a dynamic test descriptor for immediate execution with a custom, potentially no-op, execution listener.

Parameters
testDescriptor:TestDescriptor

the test descriptor to be executed; never null

executionListener:EngineExecutionListener

the executionListener to be notified; never null

Returns:Future<?>

a future to cancel or wait for the execution

Annotations
@API
status:STABLE
since:1.10
Since
1.7
See Also
EngineExecutionListener#NOOP
org.junit.platform.engine.support.hierarchical back to summary

public final Enum Node.ExecutionMode

extends Enum<Node.ExecutionMode>
Class Inheritance
Annotations
@API
status:STABLE
since:1.10
consumers:hierarchical

Supported execution modes for parallel execution.
Since
1.3
See Also
SAME_THREAD, CONCURRENT, Node#getExecutionMode()

Field Summary

Modifier and TypeField and Description
public static final Node.ExecutionMode
CONCURRENT

Allow concurrent execution with any other node.

public static final Node.ExecutionMode
SAME_THREAD

Force execution in same thread as the parent node.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Node.ExecutionMode
public static Node.ExecutionMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONCURRENTback to summary
public static final Node.ExecutionMode CONCURRENT

Allow concurrent execution with any other node.

See Also
SAME_THREAD
SAME_THREADback to summary
public static final Node.ExecutionMode SAME_THREAD

Force execution in same thread as the parent node.

See Also
CONCURRENT

Constructor Detail

ExecutionModeback to summary
private ExecutionMode()

Method Detail

valueOfback to summary
public static Node.ExecutionMode valueOf(String name)
valuesback to summary
public static Node.ExecutionMode[] values()
org.junit.platform.engine.support.hierarchical back to summary

public Interface Node.Invocation<C extends EngineExecutionContext>

Annotations
@API
status:STABLE
since:1.10
Type Parameters
<C>
the type of EngineExecutionContext used by the HierarchicalTestEngine

Represents an invocation that runs with the supplied context.
Since
1.4

Method Summary

Modifier and TypeMethod and Description
public void
invoke(C
the context to invoke in
context
)

Invoke this invocation with the supplied context.

Method Detail

invokeback to summary
public void invoke(C context) throws Exception

Invoke this invocation with the supplied context.

Parameters
context:C

the context to invoke in

org.junit.platform.engine.support.hierarchical back to summary

public Class Node.SkipResult

extends Object
Class Inheritance
  • java.lang.Object
  • org.junit.platform.engine.support.hierarchical.Node.SkipResult

The result of determining whether the execution of a given context should be skipped.
See Also
Node#shouldBeSkipped(EngineExecutionContext)

Field Summary

Modifier and TypeField and Description
private static final Node.SkipResult
private final Optional<String>
private final boolean

Constructor Summary

AccessConstructor and Description
private
SkipResult(boolean skipped, String reason)

Method Summary

Modifier and TypeMethod and Description
public static Node.SkipResult

Returns:

a do not skip SkipResult
doNotSkip
()

Factory for creating do not skip results.

public Optional<String>
getReason()

Get the reason that execution of the context should be skipped, if available.

public boolean

Returns:

true if the execution should be skipped
isSkipped
()

Whether execution of the context should be skipped.

public static Node.SkipResult

Returns:

a skipped SkipResult with the given reason
skip
(String
the reason that the context should be skipped, may be null
reason
)

Factory for creating skipped results.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

alwaysExecuteSkipResultback to summary
private static final Node.SkipResult alwaysExecuteSkipResult
reasonback to summary
private final Optional<String> reason
skippedback to summary
private final boolean skipped

Constructor Detail

SkipResultback to summary
private SkipResult(boolean skipped, String reason)

Method Detail

doNotSkipback to summary
public static Node.SkipResult doNotSkip()

Factory for creating do not skip results.

A context that is not skipped will be executed as normal.

Returns:Node.SkipResult

a do not skip SkipResult

getReasonback to summary
public Optional<String> getReason()

Get the reason that execution of the context should be skipped, if available.

isSkippedback to summary
public boolean isSkipped()

Whether execution of the context should be skipped.

Returns:boolean

true if the execution should be skipped

skipback to summary
public static Node.SkipResult skip(String reason)

Factory for creating skipped results.

A context that is skipped will be not be executed.

Parameters
reason:String

the reason that the context should be skipped, may be null

Returns:Node.SkipResult

a skipped SkipResult with the given reason

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override