PHPUnit Selenium 服务器 - 更好/自定义错误处理?
有没有办法让 PHPUnit 在发生错误后继续?例如,我有一个大型测试套件(400 多个步骤),我希望如果没有找到某个元素,它不会阻止我的脚本的其余部分继续执行。
Is there a way I can have PHPUnit just continue after an error? For example, I have a large test suite (400+ steps) and I would prefer that if say, an element is not found, it doesn't stop the rest of my script from continuing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们在 Selenium 测试中做了同样的事情。您需要捕获因断言失败而引发的异常,唯一的方法是创建一个重写断言方法的自定义测试用例基类。您可以存储失败消息并在最后使用测试侦听器使测试失败。
我面前没有代码,但它非常简单。例如,
We do the same thing in our Selenium tests. You need to catch the exceptions thrown for assertion failures, and the only way to do that is to create a custom test case base class that overrides the assertion methods. You can store the failure messages and fail the test at the end using a test listener.
I don't have the code in front of me, but it was pretty straight-forward. For example,
有一个更好的方法可以做到这一点。您可以只重载一个方法:runTest(),而不是重载每个 assert*() 方法。它针对每个断言,并且可以捕获异常:
There is a better way to do this. Instead of overloading every assert*() method you can overload just one method: runTest(). It is for each assertion, and exceptions can be caught: