Is it possible to run parameterized test for each method of test class with JUnitParams and class level annotations? Something like:
@RunWith(JUnitParamsRunner.class)
@Parameters(method = "paramsGenerator")
public class TestMethod {
public Integer[] paramsGenerator() {
return new Integer[] {1, 2, 3};
}
@Test
public void test1(Integer myInt) {
......
}
@Test
public void test2(Integer myInt) {
......
}
}
No, you cannot have a class-level parameters annotation that would cover all test methods. You must declare @Parameters(method = "paramsGenerator")
on each test method. Your use case is pretty rare - most often different test methods require different parameters (eg. you have one method for valid and one for invalid input).