我有一个参数测试类,并且我有一个测试方法,我希望它返回 IllegalArgumentException。
@RunWith(value = Parameterized.class)
public class TriangleParametrizedTest {
@Rule
public ExpectedException exception = ExpectedException.none();
enum Type {
EQUILATERAL,
NEGETIVE
};
private Type type;
private int sideA;
private int sideB;
private int sideC;
public TriangleParametrizedTest(Type type, int sideA, int sideB, int sideC) {
this.type = type;
this.sideA = sideA;
this.sideB = sideB;
this.sideC = sideC;
}
@Parameters()
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{Type.EQUILATERAL, 5, 5, 5},
{Type.NEGETIVE, -5, 5, 5},});
}
@Test()
public void negetiveSideTest() {
Assume.assumeTrue(type == Type.NEGETIVE);
exception.expect(IllegalArgumentException.class);
Triangle trianle = new Triangle(sideA, sideB, sideC);
}
}
但我收到了这个错误:初始化错误:没有找到匹配方法 negetiveSideTest 的测试。
有人有解决办法吗?