Search code examples
javajunit5

Is there an equivalent of Junit5 TestTemplateInvocationContextProvider that can be used on class level?


I use TestTemplateInvocationContextProvider as JUnit 5 extension to handle some configuration of user profile when running a test.

Something like this

@MyExtension({Config.VALUE_A, Config.VALUE_B})
void myTest(UserContext context) {
 // my test
}

This allow me to executed the test multiple time with different user configuration.

I want to allow to do the same things at class level, like this:

@MyExtension({Config.VALUE_A, Config.VALUE_B})
class MyTestSuite {

   void myTest(UserContext context) {
     // my test
   }

   void myTest2(UserContext context) {
     // my test
   }
}

So that each of my tests inside test suite is invoked multiple times. Is there an equivalent of Junit5 TestTemplateInvocationContextProvider that can be used on class level?


Solution

  • No, there is currently no support for parameterized test classes in JUnit Jupiter.

    For details, see the following open issues on the subject.