java - 将 JUnit 样式的 XML 测试输出渲染为 HTML

标签 java junit pytest

我正在使用非 Java 语言 (Python) 进行一些单元/集成测试,使用测试框架 ( py.test ),它能够生成 JUnit 样式的 XML 输出,例如如下所示:

<?xml version="1.0" encoding="utf-8"?>
<testsuite name="" errors="0" failures="0" skips="4" tests="4" time="75.956">
    <testcase classname="daemon_ping_test.SimpleDaemonTestCase" name="test_daemon_runs_plugin" time="0.000185012817383">
        <skipped type="pytest.skip" message="skipped temporarily">/usr/local/lib/python2.7/dist-packages/pytest-2.1.3-py2.7.egg/_pytest/unittest.py:88: Skipped: skipped temporarily</skipped>
    </testcase>
    <testcase classname="libvirt_handler_test.LibvirtHandlerTestcase" name="test_domain_with_iscsi" time="0.00244903564453">
    </testcase>
    <testcase classname="libvirt_handler_test.LibvirtHandlerTestcase" name="test_libvirt_controller" time="0.00547981262207">
    </testcase>
        <testcase classname="libvirt_handler_test.LibvirtHandlerTestcase" name="test_libvirt_get_vmid_by_storage" time="0.000415086746216">
        <skipped type="pytest.skip" message="temporarily disabled">/usr/local/lib/python2.7/dist-packages/pytest-2.1.3-py2.7.egg/_pytest/unittest.py:88: Skipped: temporarily disabled</skipped>
    </testcase>
    <testcase classname="test_integration.StorageTests" name="test_1_CreateTemplate" time="73.7471599579"></testcase>
    <testcase classname="test_integration.StorageTests" name="test_2_CreateStorageVol" time="0.000442981719971">
        <skipped type="pytest.skip" message="temporarily skipped">/usr/local/lib/python2.7/dist-packages/pytest-2.1.3-py2.7.egg/_pytest/unittest.py:88: Skipped: temporarily skipped</skipped>
    </testcase>
    <testcase classname="test_integration.StorageTests" name="test_3_StorageVolMap" time="0.000404119491577">
        <skipped type="pytest.skip" message="temporarily skipped">/usr/local/lib/python2.7/dist-packages/pytest-2.1.3-py2.7.egg/_pytest/unittest.py:88: Skipped: temporarily skipped</skipped>
    </testcase>
    <testcase classname="test_integration.StorageTests" name="test_4_RemoveTemplate" time="1.97415280342">
    </testcase>
</testsuite>

现在我想将这些结果呈现为人类可读的 HTML 文件。有没有什么工具可以做到这一点?

最佳答案

Ant 可能是最简单的方法。您可以使用 junit-report 任务,如下所示..

<junitreport todir="./reports">
   <fileset dir=".">
    <include name="**/*.xml" />
   </fileset>
   <report format="frames" todir="./reports/html" />
</junitreport>

关于java - 将 JUnit 样式的 XML 测试输出渲染为 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8034848/

相关文章:

testing - Python 动态测试计划生成

java - 如何将 picoCLI 项目变成命令?

java - Java 中的强制覆盖字段

java - Selenium Java : Unable to upload a file via custom upload

java - ubuntu 1204中的环境

maven - 使用 Maven Surefire 运行嵌套的 JUnit 5 测试

testing - 等待一个链接出现,该链接已经在 selenium 的页面中

python - 为什么 Pytest 对 fixture 参数执行嵌套循环

java - JPA 单元测试 - 查询返回比以往任何时候都多的实体

python - 设置 pymysql 以与 django、pytest 和 pytest-django 一起工作