我使用TestNG作为测试框架,使用Intellij IDEA运行测试。如果某些软断言失败,那么我会收到重复的错误消息。这是我的测试方法:
list.sort
在我得到的输出中:
@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>