更新时间:2023-11-23 16:00:22
Selenium IDE使用verify来执行软断言,这意味着测试即使检查失败也会继续,并在测试结束时或在硬判断事件中报告失败。
Selenium IDE uses verify to perform a soft assertion, meaning that the test will continue even if the check fails and either report the failures at the end of the test or on the event of a hard assertion.
使用TestNG可以使用这些通过使用自定义测试侦听器进行软断言。我已经记录了如何在我的博客上执行此操作: http://davehunt.co.uk/2009/10/08/using-soft-assertions-in-testng.html
With TestNG it is possible to have these soft assertions by using custom test listeners. I have documented how to do this on my blog: http://davehunt.co.uk/2009/10/08/using-soft-assertions-in-testng.html
基本上,你需要创建自己的验证*
方法,在这些方法中,您可以捕获断言失败并将它们添加到地图中。然后在自定义 afterInvocation
侦听器中,如果地图不为空,则可以将测试设置为失败。
Basically, you need to create your own verify*
methods, in these you can catch assertion failures and add them to a map. Then in a custom afterInvocation
listener you can set the test to failed if the map is not empty.