【发布时间】:2014-11-10 22:33:50
【问题描述】:
我想知道如何为特定的异常断言编写测试?
例如(我的测试数据容器):
@Parameters(name = "{index}: {0} > {1} > {2} > {3} > {4}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
{"1200", new byte[] {0x4B0}, "1200", 16, 2},
{"10", new byte[] {0x0A}, "10", 8, 1},
{"13544k0", new byte[] {0x0A}, "1200", 8, 1}, <== assert thrown exception
{"132111115516", new byte[] {0x0A}, "1200", 8, 1},<== assert thrown exception
});
}
是否可以使用这样的容器数据来断言异常,或者我需要在具体的测试方法中建模情况?
【问题讨论】:
-
你在测试什么?
标签: java unit-testing exception junit parameterized