RFR: 7903930: Support running individual parameterized tests and @Nested test classes [v8]
Christian Stein
cstein at openjdk.org
Mon Jan 20 17:18:53 UTC 2025
On Mon, 20 Jan 2025 17:04:43 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> I noticed that there's also a nested-class and nested-method selector. Is there a reason for keeping these separate? Or is it fine to use the class and method selectors as well, which work as long as you use the binary name of the nested class?
Binary names for classes and nested classes are fine. These two nested variants can be used for "lazy load" scenarios. See for example the API documentation of `NestedMethodSelector`
> A [DiscoverySelector](https://junit.org/junit5/docs/current/api/org.junit.platform.engine/org/junit/platform/engine/DiscoverySelector.html) that selects a nested [Method](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/reflect/Method.html) or a combination of enclosing classes names, class name, method name, and parameter types so that [TestEngines](https://junit.org/junit5/docs/current/api/org.junit.platform.engine/org/junit/platform/engine/TestEngine.html) can discover tests or containers based on methods.
If a Java [Method](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/reflect/Method.html) is provided, the selector will return that [method](https://junit.org/junit5/docs/current/api/org.junit.platform.engine/org/junit/platform/engine/discovery/NestedMethodSelector.html#getMethod()) and its method name, class name, enclosing classes names, and parameter types accordingly. If class names or method names are provided, this selector will only attempt to lazily load a class or method if [getEnclosingClasses()](https://junit.org/junit5/docs/current/api/org.junit.platform.engine/org/junit/platform/engine/discovery/NestedMethodSelector.html#getEnclosingClasses()), [getNestedClass()](https://junit.org/junit5/docs/current/api/org.junit.platform.engine/org/junit/platform/engine/discovery/NestedMethodSelector.html#getNestedClass()), [getMethod()](https://junit.org/junit5/docs/current/api/org.junit.platform.engine/org/junit/platform/engine/discovery/NestedMethodSelector.htm
l#getMethod()), or [getParameterTypes()](https://junit.org/junit5/docs/current/api/org.junit.platform.engine/org/junit/platform/engine/discovery/NestedMethodSelector.html#getParameterTypes()) is invoked.
-------------
PR Comment: https://git.openjdk.org/jtreg/pull/241#issuecomment-2602934527
More information about the jtreg-dev
mailing list