Class ParameterizedTestExtension
java.lang.Object
org.operaton.bpm.engine.test.junit5.ParameterizedTestExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
public class ParameterizedTestExtension
extends Object
implements org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
This JUnit 5 extension is intended to make the conversion from JUnit 4 Tests
like ContainerAuthenticationFilterTest as easy as possible. The issue is,
that these tests are run with @RunWith(org.junit.runners.Parameterized.class)
and use a static method annotated
with @org.junit.runners.Parameterized.Parameters to inject parameters into
the constructor of the test class or by using field injection
with @Paramater(0), @Parameter(1). This extension implements the same
mechanism for JUnit 5.
To migrate the tests you can follow the following recipe:
- Remove the junit 4 imports
import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters;
- Add the imports for junit 5 and this class
import org.junit.jupiter.api.*; import org.operaton.bpm.engine.test.junit5.ParameterizedTestExtension.Parameterized; import org.operaton.bpm.engine.test.junit5.ParameterizedTestExtension.Parameters; import org.operaton.bpm.engine.test.junit5.ParameterizedTestExtension.Parameter;
- Replace the class @RunWith(Parameterized.class) annotation with @Parameterized
- Replace @Before with @BeforeEach and @After with @AfterEach
- Replace each @Test with @TestTemplate
- Use assertion methods from Assertions instead from Assert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfacestatic @interfacestatic @interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionStream<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext context) booleansupportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
mayReturnZeroTestTemplateInvocationContexts
-
Constructor Details
-
ParameterizedTestExtension
public ParameterizedTestExtension()
-
-
Method Details
-
supportsTestTemplate
public boolean supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
supportsTestTemplatein interfaceorg.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
-
provideTestTemplateInvocationContexts
public Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
provideTestTemplateInvocationContextsin interfaceorg.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
-