I have a bunch of parameterized JUnit4 tests which all look like:
@RunWith(Parameterized.class)
public class MyTestX {
private final MyParameter param;
public TestX(MyParameter param) {
this.param = param;
}
@Test
public void myTest() {
// Some test code
}
}
I want to run them from different test suites, each with a different value for MyParameter.
I tried the following:
@RunWith(Suite.class)
@SuiteClasses( { MyTest1.class, MyTest2.class, ... })
public class MyTestSuite1 {
@Parameters
public static Collection<Object[]> data() {
Object[][] data = {{ new MyParameter(1) )}};
return Arrays.asList(data);
}
}
But it does not work: I get "No public static parameters method on class MyTestX".
Is there a way to specify the parameters from the test suite instead of the testcase? I would like to avoid creating a new class for each test, for each test suite, if possible.