3

I'm doing some Unit/Integration testing in a Non-Java language (Python), using a test-framework (py.test) which is able to produce JUnit-style XML output, for example like this:

<?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>

Now I would like to render these results to a human-readable HTML file. Is there any tool out there to do that?

Wolkenarchitekt
  • 20,170
  • 29
  • 111
  • 174
  • 1
    Potential duplicate question with more answers: [How can I generate an HTML report for Junit results?](https://stackoverflow.com/questions/2385553/how-can-i-generate-an-html-report-for-junit-results) – luator Dec 18 '19 at 08:42

2 Answers2

2

Ant is probably the easiest way to do that. You can use the junit-report task, like so..

<junitreport todir="./reports">
   <fileset dir=".">
    <include name="**/*.xml" />
   </fileset>
   <report format="frames" todir="./reports/html" />
</junitreport>
Khai Do
  • 68
  • 4
1

The other way is to use XSLT processor to write it. Define an xsl stylesheet, and then run it with:

xsltproc --output tests.html your.xsl path/to/tests.xml
Brett
  • 5,690
  • 6
  • 36
  • 63
  • (I think I actually used an xsl from within 1 of the junit jars, so the HTML report is almost the same as if it was run by ant). – Brett Aug 08 '13 at 12:01