RFR: CODETOOLS-7903267: Support executing a single test method in a JUnit class [v2]
Iris Clark
iris at openjdk.org
Tue Sep 13 17:52:14 UTC 2022
On Tue, 13 Sep 2022 17:36:04 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:
>> Please review a medium-sized patch to support new feature that provides a way to specify that only parts of a test should be executed. For JUnit tests, this allows a single method in the test to be executed, but the underlying mechanism is more general than that and can be leveraged by any framework that supports running many test cases within an overall test.
>>
>> The feature is enabled by using a new syntactic form on the command line, informally called _query syntax_: `path-to-test?string`. The syntax is based on URL syntax, but note that unlike URLs, the query component comes at the end, and not before any fragment component. In other words, the full syntax is `path#id?string`. Generally, this reflects the hierarchical structure: a path to a file, a test description within the file, and a string to specify part of the test to be run.
>>
>> In terms of implementation, the "heavy lifting" is done in `TestManager`, to track the _file, id, query_ tuple, as compared to the previous _file, id_. New abstractions `TestSpec` and `GroupSpec` are introduced, to replace stylistic use of simple strings.
>>
>> The underlying JT Harness does not know (or need to know) about query components and so is unchanged. But the back end `RegressionScript` used to execute each test _does_ need to know the query component, and so the information about which tests involve a query component is tunneled through the `RegressionParameters` in a side channel, embodied by a new resource in the object. In itself, the `RegressionScript` has little to do with the query component, it is simply passed down to the actions of the test in a new `test.query` property or `TESTQUERY` environment variable.
>>
>> `JUnitRunner` is updated to check for the new `test.query` property: if set, it is used as the name of a test method to be run. Note: a JUnit exception will be thrown and the test will fail if the method is not found. The exception does contain enough useful information to diagnose the issue, but we may want to detect and report the issue in a more friendly form in a followup change.
>>
>> Finally, new jtreg self-tests are added to exercise the new feature.
>
> Jonathan Gibbons has updated the pull request incrementally with one additional commit since the last revision:
>
> Address review feedback
Updates look good. Thanks!
-------------
Marked as reviewed by iris (Reviewer).
PR: https://git.openjdk.org/jtreg/pull/115
More information about the jtreg-dev
mailing list