考虑以下代码:
@DataPoints
public static String[] validDates() {
return new String[]{
"1930",
"1930-10",
"1930-50-10"};
}
@Theory
public void dateTest(String dateStr) throws DataException {
Assert.assertEquals(Status.PASSED, verifyDate(dateStr));
}
输出:
org.junit.experimental.theories.internal.ParameterizedAssertionError: dateTest(validDates[2])
...
Caused by: java.lang.AssertionError: expected:<PASSED> but was:<FAILED>
...
有没有办法轻松修改异常堆栈更具体,日期值&#34; 1930-50-10&#34;而不是validDates [2]?
尝试/捕获AssertionError然后抛出另一个自定义异常?