Liked TestNG DataProviders but have to use JUnit?
This is an example how to use TestNG like DataProviders in JUnit.
JUnit DataProviders Maven dependency
DataProvider in JUnit tests
First of all you need to annotate your test class with @RunWith(DataProviderRunner.class)
Then create DataProvider
To use that data provider you should annotate you test with @UseDataProvider("sumTestData")
.
JUnit DataProvider example
It’s working…
… but why doesn’t JUnit support it from the box?
Want to use DataProviders with JUnit and Spring? This is another pain…
You may also find these posts interesting: