Skip to content

Introduce support for parameterized tests #14

@elygre

Description

@elygre

Deliverables

  • Introduce @TestTemplate and accompanying extension point.
  • Determine if Parameter resolvers should be able to access the invocation context for test templates #704 should be included in M4.
  • Determine if we need an @InvocationIndex annotation or TestTemplateInfo type for injecting the current invocation index, etc. into @Test, @BeforeEach, and @AfterEach methods.
  • Introduce junit-jupiter-params module
  • Document @TestTemplate and accompanying extension point in User Guide and Release Notes
  • Document parameterized tests in User Guide and Release Notes
    • Document the junit-jupiter-params module in the Dependency Metadata section.
    • Document the junit-jupiter-params module in the Dependency Diagram.
    • Provide example(s) in the documentation module and include in the User Guide.

Original Issue Description

At the time of writing, the https://github.com/junit-team/junit-lambda/wiki/Prototype-Test-Decorators page does not have all that much detail, so this might already be considered.

It would be good if the library shipped with ready-to-use simple parameter annotations that could be used inside a single test instance. It would in many ways look like JUnit 4's @Parameterized Runner, but for use inside a single class. When running the test, each @Parameterized method would appear many times, once for each data set.

class MyTest {

   // A simple test with a specified data set
   @Test @Parameterized("mod10")
   void testMod10(String value) { ... }

   @Parameterized("mod10") 
   Collection<Object[]> getMod10Values { ... }

   // Also including a method naming convention
   @Test @Parameterized("mod11", name="{0}")
   void testMod11(String value) { ... }

   @Parameterized("mod11")
   Collection<Object[]> getMod11Values { ... }

   // In the absense of a @Parameterized data provider, use reflection
   @Test @Parameterized("getMod12Values", name="{0}")
   void testMod12(String value) { ... }

   Collection<Object[]> getMod12Values{ ... }
}

Related Issues

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions