diff --git a/junit-platform-engine/src/main/java/org/junit/platform/engine/TestDescriptor.java b/junit-platform-engine/src/main/java/org/junit/platform/engine/TestDescriptor.java index 8d146c05b616..6a6b44134282 100644 --- a/junit-platform-engine/src/main/java/org/junit/platform/engine/TestDescriptor.java +++ b/junit-platform-engine/src/main/java/org/junit/platform/engine/TestDescriptor.java @@ -27,8 +27,8 @@ import org.junit.platform.commons.util.Preconditions; /** - * Mutable descriptor for a test or container that has been discovered by a - * {@link TestEngine}. + * Mutable descriptor for a test or container that has + * been discovered by a {@link TestEngine}. * * @since 1.0 * @see TestEngine @@ -106,6 +106,9 @@ default String getLegacyReportingName() { /** * Get the immutable set of children of this descriptor. * + *

The implementation must be consistent with {@link #isContainer()} such that + * {@code !x.container()} implies {@code x.getChildren().isEmpty()}. + * * @return the set of children of this descriptor; neither {@code null} * nor mutable, but potentially empty * @see #getDescendants() @@ -141,6 +144,9 @@ default Set getAncestors() { *

A descendant is a child of this descriptor or a child of one of * its children, recursively. * + *

The implementation must be consistent with {@link #isContainer()} such that + * {@code !x.container()} implies {@code x.getDescendants().isEmpty()}. + * * @see #getChildren() */ default Set getDescendants() { @@ -230,7 +236,11 @@ default boolean isRoot() { Type getType(); /** - * Determine if this descriptor describes a container. + * Determine if this descriptor describes a container. + * + *

A test descriptor is a container when it may contain other + * containers or tests as its children. A container can also be a + * test. * *

The default implementation delegates to {@link Type#isContainer()}. */ @@ -239,7 +249,11 @@ default boolean isContainer() { } /** - * Determine if this descriptor describes a test. + * Determine if this descriptor describes a test. + * + *

A test descriptor is a test when it verifies expected + * behavior when executed. A test can also be a + * container. * *

The default implementation delegates to {@link Type#isTest()}. */ @@ -250,6 +264,9 @@ default boolean isTest() { /** * Determine if this descriptor may register dynamic tests during execution. * + *

The implementation must be consistent with {@link #isContainer()} such that + * {@code !x.container()} implies {@code !x.mayRegisterTests()}. + * *

The default implementation assumes tests are usually known during * discovery and thus returns {@code false}. */ @@ -259,7 +276,7 @@ default boolean mayRegisterTests() { /** * Determine if the supplied descriptor (or any of its descendants) - * {@linkplain TestDescriptor#isTest() is a test} or + * {@linkplain TestDescriptor#isTest() is a test} or * {@linkplain TestDescriptor#mayRegisterTests() may potentially register * tests dynamically}. * @@ -355,12 +372,14 @@ static Visitor composite(Visitor... visitors) { enum Type { /** - * Denotes that the {@link TestDescriptor} is for a container. + * Denotes that the {@link TestDescriptor} is strictly for a + * container. I.e. it is not also a test. */ CONTAINER, /** - * Denotes that the {@link TestDescriptor} is for a test. + * Denotes that the {@link TestDescriptor} is strictly for a + * test. I.e. it is not also a container. */ TEST,