I am using spring boot starter test for writing JUnit test cases. I would love to use JunitParamrunner which facilitates passing files for parameterized test.Basically it reads data from file line by line and for every line invoke a test case. The issue is to use both I need to pass @RunWith with both SpringJUnit4ClassRunner as well as JUnitParamsRunner. I am not able to figure out how to do that. Can any one provide some leads.
SpringClassRule mentioned by @wjans if the best solution, but if your Spring version is less than 4.2 (the latest spring-boot-starter-test depends on spring version 4.1.7), you can initialize the context in test constructor:
@ContextConfiguration(<your context location>)
@RunWith(JUnitParamsRunner.class)
public class ParameterizedTestWithSpring {
private TestContextManager testContextManager;
public ParametrizedTestWithSpring() throws Exception {
this.testContextManager = new TestContextManager(getClass());
this.testContextManager.prepareTestInstance(this);
}
// your test methods