with theories you can write something like:
@RunWith(Theories.class)
public class MyTheoryOnUniverseTest {
@DataPoint public static int a1 = 1;
@DataPoint public static int a2 = 2;
@DataPoint public static int a3 = 3;
@DataPoint public static int a4 = 4;
@DataPoint public static int b2 = 2;
@DataPoint public static int b3 = 3;
@DataPoint public static int b4 = 4;
@DataPoint public static int b5 = 5;
@DataPoint public static int b6 = 6;
@Theory
public void checkWith(int a, int b) {
System.out.format("%d, %d\n", a, b);
}
}
(tested with JUnit 4.5)
EDIT
Theories also generate nice error messages:
Testcase: checkWith(MyTheoryOnUniverseTest): Caused an ERROR
checkWith(a1, b2)
, .
EDIT2
DataPoint s:
@DataPoints public static int as[] = { 1, 2, 3, 4} ;
@DataPoints public static int bs[] = { 2, 3, 4, 5, 6};
@Theory
public void checkWith(int a, int b) {
System.out.format("%d, %d\n", a, b);
}