【发布时间】:2015-03-23 04:27:39
【问题描述】:
我在我的代码中使用了 TestNG 软断言。
public class AssertionTest{
private SoftAssert softAssert = new SoftAssert();
@Test(enabled = true)
public void testSoftAssertion(){
softAssert.assertTrue(false);
softAssert.assertTrue(true);
softAssert.assertEquals("India", "US");
softAssert.assertAll();
}
}
当测试执行完成时,测试失败(如预期)但结果没有提供详细信息,而是提供如下信息,这无助于理解哪些断言失败。
FAILED: testSoftAssertion
java.lang.AssertionError: The following asserts failed:
null, null
我期待输出有助于理解结果的输出(这种类型的输出是在我们使用硬断言时生成的,即使用Assert 类)。
FAILED: testSoftAssertion
java.lang.AssertionError: The following asserts failed:
expected [true] but found [false]
expected [India] but found [US]
这是 TestNG 软断言的已知缺陷/缺点还是我遗漏了什么?
【问题讨论】:
标签: java selenium-webdriver testng