Skip to content

Commit 5df9b98

Browse files
committed
Polish TestDescriptor.containsTests()
This commit improves the Javadoc and checks the precondition.
1 parent 0ad9b93 commit 5df9b98

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Set;
1919

2020
import org.apiguardian.api.API;
21+
import org.junit.platform.commons.util.Preconditions;
2122

2223
/**
2324
* Mutable descriptor for a test or container that has been discovered by a
@@ -195,10 +196,18 @@ default boolean mayRegisterTests() {
195196
}
196197

197198
/**
198-
* Determine if the supplied descriptor or any of its descendants contains
199-
* any tests.
199+
* Determine if the supplied descriptor (or any of its descendants)
200+
* {@linkplain TestDescriptor#isTest() is a test} or
201+
* {@linkplain TestDescriptor#mayRegisterTests() may potentially register
202+
* tests dynamically}.
203+
*
204+
* @param testDescriptor the {@code TestDescriptor} to check for tests; never
205+
* {@code null}
206+
* @return {@code true} if the descriptor is a test, contains tests, or may
207+
* later register tests dynamically
200208
*/
201209
static boolean containsTests(TestDescriptor testDescriptor) {
210+
Preconditions.notNull(testDescriptor, "TestDescriptor must not be null");
202211
return testDescriptor.isTest() || testDescriptor.mayRegisterTests()
203212
|| testDescriptor.getChildren().stream().anyMatch(TestDescriptor::containsTests);
204213
}

0 commit comments

Comments
 (0)