package jp.mirageworld.webapps.util;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class ParameterizedTest {
@Parameters
public static final List<Object[]> parameters() {
return Arrays.asList(new Object[][] {
{ 1, 2, 3, "X", NumberFormatException.class },
{ 2, 3, 5, "0", null },
});
};
int a;
int b;
int c;
String n;
Class<?> clazz;
public ParameterizedTest(int a, int b, int c, String n, Class<?> clazz) {
this.a = a;
this.b = b;
this.c = c;
this.n = n;
this.clazz = clazz;
}
@Test
public void test() {
try {
assertEquals(a + b, c);
Long.parseLong(n);
assertNull(clazz);
} catch (Exception e) {
assertEquals(e.getClass(), clazz);
}
}
}