java SoftAssert两次显示错误消息
我使用Intellij IDEA运行测试,使用TestNG作为测试框架。如果一些软断言失败,那么我会收到重复的错误消息。以下是我的测试方法:
@Test
public void canNotContinueWithoutMandatoryInfo() {
applicant.continueExpectingErrors();
SoftAssert sf = new SoftAssert();
for (String label : fields) {
sf.assertEquals(applicant.getFieldRequiredNotification(label), fieldIsMandatoryError, "Notification for " +
label + " is either invalid or missing\n");
}
sf.assertAll();
}
我得到的结果是:
java.lang.AssertionError: The following asserts failed:
Notification for field Account is either invalid or missing
Notification for field Account is either invalid or missing
expected [This field is mandatory.] but found [null],
Notification for field Name is either invalid or missing
Notification for field Name väli is either invalid or missing
Expected :This field is mandatory.
Actual :null
<Click to see difference>
我做错了什么
您可以通过运行这样一个简单的测试来重现这一点:
@Test
public void test() {
SoftAssert sf = new SoftAssert();
Integer[] list = {1, 2, 3};
for(int i : list)
sf.assertEquals(3, i, i + " does not equal 3\n");
sf.assertAll();
}
共 (0) 个答案