Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions