Skip to content

Commit 7bce0ed

Browse files
committed
Document test and container are non-exclusive properties
* Define test and container as non-exclusive properties. * Use emphasis to distinguish between term and word. * Document that TestDescriptor.Type values are exclusive properties. * Document that `getChildren()`, `getDescendants()` and `mayRegisterTests()` must be consistent with `isContainer()`.
1 parent 99c3d88 commit 7bce0ed

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

junit-platform-engine/src/main/java/org/junit/platform/engine/TestDescriptor.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import org.junit.platform.commons.util.Preconditions;
2828

2929
/**
30-
* Mutable descriptor for a test or container that has been discovered by a
31-
* {@link TestEngine}.
30+
* Mutable descriptor for a test or container that has
31+
* been discovered by a {@link TestEngine}.
3232
*
3333
* @since 1.0
3434
* @see TestEngine
@@ -106,6 +106,9 @@ default String getLegacyReportingName() {
106106
/**
107107
* Get the immutable set of <em>children</em> of this descriptor.
108108
*
109+
* <p>The implementation must be consistent with {@link #isContainer()} such that
110+
* {@code !x.container()} implies {@code x.getChildren().isEmpty()}.
111+
*
109112
* @return the set of children of this descriptor; neither {@code null}
110113
* nor mutable, but potentially empty
111114
* @see #getDescendants()
@@ -141,6 +144,9 @@ default Set<? extends TestDescriptor> getAncestors() {
141144
* <p>A <em>descendant</em> is a child of this descriptor or a child of one of
142145
* its children, recursively.
143146
*
147+
* <p>The implementation must be consistent with {@link #isContainer()} such that
148+
* {@code !x.container()} implies {@code x.getDescendants().isEmpty()}.
149+
*
144150
* @see #getChildren()
145151
*/
146152
default Set<? extends TestDescriptor> getDescendants() {
@@ -230,7 +236,11 @@ default boolean isRoot() {
230236
Type getType();
231237

232238
/**
233-
* Determine if this descriptor describes a container.
239+
* Determine if this descriptor describes a <em>container</em>.
240+
*
241+
* <p>A test descriptor is a <em>container</em> when it may contain other
242+
* containers or tests as its children. A <em>container</em> can also be a
243+
* <em>test</em>.
234244
*
235245
* <p>The default implementation delegates to {@link Type#isContainer()}.
236246
*/
@@ -239,7 +249,11 @@ default boolean isContainer() {
239249
}
240250

241251
/**
242-
* Determine if this descriptor describes a test.
252+
* Determine if this descriptor describes a <em>test</em>.
253+
*
254+
* <p>A test descriptor is a <em>test</em> when it verifies expected
255+
* behavior when executed. A <em>test</em> can also be a
256+
* <em>container</em>.
243257
*
244258
* <p>The default implementation delegates to {@link Type#isTest()}.
245259
*/
@@ -250,6 +264,9 @@ default boolean isTest() {
250264
/**
251265
* Determine if this descriptor may register dynamic tests during execution.
252266
*
267+
* <p>The implementation must be consistent with {@link #isContainer()} such that
268+
* {@code !x.container()} implies {@code !x.mayRegisterTests()}.
269+
*
253270
* <p>The default implementation assumes tests are usually known during
254271
* discovery and thus returns {@code false}.
255272
*/
@@ -259,7 +276,7 @@ default boolean mayRegisterTests() {
259276

260277
/**
261278
* Determine if the supplied descriptor (or any of its descendants)
262-
* {@linkplain TestDescriptor#isTest() is a test} or
279+
* {@linkplain TestDescriptor#isTest() is a <em>test</em>} or
263280
* {@linkplain TestDescriptor#mayRegisterTests() may potentially register
264281
* tests dynamically}.
265282
*
@@ -355,12 +372,14 @@ static Visitor composite(Visitor... visitors) {
355372
enum Type {
356373

357374
/**
358-
* Denotes that the {@link TestDescriptor} is for a <em>container</em>.
375+
* Denotes that the {@link TestDescriptor} is strictly for a
376+
* <em>container</em>. I.e. it is not also a <em>test</em>.
359377
*/
360378
CONTAINER,
361379

362380
/**
363-
* Denotes that the {@link TestDescriptor} is for a <em>test</em>.
381+
* Denotes that the {@link TestDescriptor} is strictly for a
382+
* <em>test</em>. I.e. it is not also a <em>container</em>.
364383
*/
365384
TEST,
366385

0 commit comments

Comments
 (0)