Skip to content

Provide a way to generate deeper test trees using @ParameterizedTest #5110

@britter

Description

@britter

@ParameterizedTest is a great feature to implement data-driven tests with little boilerplate code. The introduction of Named and the changes in #3818 further improved this by making it easier to assign names to argument sets.

However if I want to further group my arguments, I need to use more complex features such as @Nested or @TestFactory. It would be great if @ParameterizedTest provided a way to introduce deeper nesting in the test tree.

For example with the following:

@MethodSource("provideGrouped")
@ParameterizedTest
void test(String name, int value) {
// ...
}

static Stream<Arguments> provideGrouped() {
  return Stream.of(
    argumentSet("group-1", arguments("one", 1), arguments("two", 2)),
    argumentSet("group-2", arguments("Monday", 1), arguments("Tuesday", 2)),
  );
}

I'd like to have the following test tree:

- test(String, int)
-- group-1 
---- "one", 1
---- "two", 2
-- group-2
---- "Monday", 1
---- "Tuesday", 2

Of course this should work with deeper nesting, @ParameterizedClass, and nested Named arguments ;)

Deliverables

  • Deeply nested test trees based on @ParameterizedTest and Arguments

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions