我在列表中使用failafe和Junit进行了几个测试用例,如下所示:
@Test
public void testResults() {
for (TestCase test : TestCaseList) {
int result = test.getActualResult();
int expected = test.getExpectedResult();
if (result != expected) {
System.out.println("Failed test " + test.getTestInfo());
}
assertEquals(result, expected);
}
}
我希望报告类似:
Failed test <test description here>
java.lang.AssertionError:
Expected: is <4>
but: was <2>
而不仅仅是:
java.lang.AssertionError:
Expected: is <4>
but: was <2>
有没有办法用Junit或其他框架做到这一点?
答案 0 :(得分:0)
您可以向断言添加消息:
assertEquals(test.getTestInfo(), result, expected);
这会创建以下报告:
java.lang.AssertionError: <test description here>
Expected: is <4>
but: was <2>