单击故障在 HTML 生成的 Junit 报告中不显示任何内容
我有一个 Junit html 报告,它是通过 ant 脚本使用
这是显示问题的屏幕截图。同样,这种情况仅发生在断言失败的情况下,而不会发生在测试中出现意外错误的情况下。
I have a Junit html report that is generated from an ant script with the <junitreport> element. Everything looks great except for when I try to view failures, nothing is enumerated in the appropriate frame. I have to click on the test case itself to view all methods that were tested in order to see the failures. This does not apply to errors, only failures.
Here is a screenshot showing the problem. Again, this only happens with the failed assertions, not with unexpected errors within the tests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了这个问题。为了正确地使用 Junit4 从 Ant 运行我们的 Junit3 格式的测试,我必须将以下方法添加到每个测试用例中:
这样做的问题是,对于失败和错误,JUnit4TestAdapter 将它们添加为错误。我最终不得不覆盖
Junit4TestAdapterCache.testAsductionFailure(Failure failure)
并确保它运行result.addFailure(Test, AssertionFailedError)
而不是result.addError(测试,可抛出)
。然后,我必须确保我的自定义运行程序在发生故障(而不是错误)时运行RunNotifier.fireTestAsductionFailed
。I figured out the issue. In order to properly have our Junit3 formatted tests run from Ant using Junit4, I had to add the following method to each of my test cases:
The issue with this is that for both failures and errors, the JUnit4TestAdapter adds them as errors. I ended up having to override
Junit4TestAdapterCache.testAssumptionFailure(Failure failure)
and make sure that it ranresult.addFailure(Test, AssertionFailedError)
instead ofresult.addError(Test, Throwable)
. I then had to make sure my custom runner ranRunNotifier.fireTestAssumptionFailed
when a failure (and not an error) occurred.