Is there a way to have parameterized tests in JUnit Jupiter
(Junit5
)?
@RunWith(Parameterized.class)
Background:
I went through How to write junit tests for interfaces? and wanted to implement test cases as answered here using JUnit5. But couldn't find the same class/es in the Jupiter package.
Attempts:
Looking further for substitutes I found that Extensions would be replacing the @RunWith as stated in Migrating tips
@RunWith no longer exists; superseded by @ExtendWith.
I tried defining a CustomExtension
as provided in the sample here - MockitoExtension but couldn't succeed in getting to use the instances of classes Parameterized.
Looking forward to suggestions on how to test interfaces with parameterized instances of classes implementing it in JUnit5
.
JUnit 5 M4 was just released and now supports parameterized tests.
Here's the "Hello World" example:
Please refer to the User Guide for the full documentation and additional examples.