RFR: 7903930: Support running individual parameterized tests and @Nested test classes

Christian Stein cstein at openjdk.org
Tue Jan 14 15:43:10 UTC 2025


On Mon, 13 Jan 2025 13:19:55 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> See the JBS issue for an extended problem description.
> 
> This PR adds support for running individual parameterized JUnit test methods, as well as nested test classes, by extending the format that a query string can have. The new proposed format is as follows:
> 
> 
> <class name>[::<method name>([<param type>[...,<param type>]])]
> 
> 
> For example, running a method `foo` that takes no parameters would be done using `<test name>?TestClass::foo()`. If `foo` has parameters, then at least for JUnit tests they have to be specified as a comma separated list of binary names between the parentheses. For example:
> 
> 
> TestDowncallScope::testDowncall(int,java.lang.String,CallGeneratorHelper$Ret,java.util.List,java.util.List)
> 
> 
> The delimiting characters I choose here `::` and `(...)` have to be quoted when passed through most shells. If this is deemed to be an issue, we could also change the separators for class name/method name/parameters to simple hyphens. Although, in cases where a `$` sign appears in the binary name of a nested class, quoting would be needed either way. (I would personally choose to always quote the argument, just to be sure, so I don't mind using `::` and `(...)`).
> 
> This support is intended to be used by the intellij plugin to support running individual methods and nested classes (see https://github.com/openjdk/jtreg/pull/240).
> 
> Testing: I've added additional tests for the new cases (as far as I know, TestNG does not support nested test classes though). I've also been using a PoC of this feature as the basis for similar support in the intellij plugin that I'm working on.

Implementation and associated tests look good on first sight! Will do some local experiments tomorrow.

Please, also update related sections/phrases in the FAQ document, for example: 
- https://github.com/openjdk/jtreg/blob/master/src/share/doc/javatest/regtest/faq.md#how-do-i-specify-which-tests-to-run
- https://github.com/openjdk/jtreg/blob/master/src/share/doc/javatest/regtest/faq.md#how-do-i-run-a-single-test-method-in-a-junit-test

-------------

PR Comment: https://git.openjdk.org/jtreg/pull/241#issuecomment-2590283225


More information about the jtreg-dev mailing list