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

Jorn Vernee jvernee at openjdk.org
Mon Jan 13 13:31:29 UTC 2025


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.

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

Commit messages:
 - Support running individual parameterized methods & nested test classes

Changes: https://git.openjdk.org/jtreg/pull/241/files
  Webrev: https://webrevs.openjdk.org/?repo=jtreg&pr=241&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903930
  Stats: 325 lines in 8 files changed: 269 ins; 5 del; 51 mod
  Patch: https://git.openjdk.org/jtreg/pull/241.diff
  Fetch: git fetch https://git.openjdk.org/jtreg.git pull/241/head:pull/241

PR: https://git.openjdk.org/jtreg/pull/241


More information about the jtreg-dev mailing list