如何为 Junit 结果生成 HTML 报告? [英] How can I generate an HTML report for Junit results?
问题描述
有没有办法(轻松)生成包含测试结果的 HTML 报告?除了 Selenium 之外,我目前还使用 JUnit 来测试 Web 应用程序 UI.
Is there a way to (easily) generate a HTML report that contains the tests results ? I am currently using JUnit in addition to Selenium for testing web apps UI.
PS:鉴于项目结构,我不应该使用 Ant :(
PS: Given the project structure I am not supposed to use Ant :(
推荐答案
如果您可以使用 Ant,那么您只需使用 JUnitReport 任务,如下所述:http://ant.apache.org/manual/Tasks/junitreport.html,但您在问题中提到您'不应该使用Ant.我相信该任务只是将 XML 报告转换为 HTML,因此使用任何 XSLT 处理器来生成类似的报告都是可行的.
If you could use Ant then you would just use the JUnitReport task as detailed here: http://ant.apache.org/manual/Tasks/junitreport.html, but you mentioned in your question that you're not supposed to use Ant. I believe that task merely transforms the XML report into HTML so it would be feasible to use any XSLT processor to generate a similar report.
或者,您可以切换到使用 TestNG ( http://testng.org/doc/index.html ) 与 JUnit 非常相似,但具有默认的 HTML 报告以及其他几个很酷的功能.
Alternatively, you could switch to using TestNG ( http://testng.org/doc/index.html ) which is very similar to JUnit but has a default HTML report as well as several other cool features.
这篇关于如何为 Junit 结果生成 HTML 报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!