Skip to content

Cache generated {arguments} patterns for parameterized tests #4804

@sbrannen

Description

@sbrannen

Overview

Currently, {arguments} patterns are generated for every @ParameterizedTest and @ParameterizedClass, which results in generation of the same pattern strings potentially hundreds of times per test suite.

Without any form of caching, JUnit Jupiter generates strings like "{0}, {1}", "{0}, {1}, {2}", "{0}, {1}, {2}, {3}", etc. each time such a pattern is needed.

For example, when running JupiterTestSuite we currently generate {arguments} patterns 330 times. Whereas, with caching we only generate {arguments} patterns 10 times.

Proposal

To prevent regeneration of identical patterns, we should cache each generated pattern in a map, keyed by the number of arguments.

Since #4783, we now generate identical patterns for the {arguments} and {argumentsWithNames} placeholders. Specifically, the argumentsWithNamesPattern() method was removed from ParameterizedInvocationNameFormatter in commit b9618a8. In light of that it makes even more sense to cache the results.

Related Issues

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions