Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i create a html report for the junit xml report manually?

I have run junit and it shows the results in Junit console, then i do a export of the result, it is saved as some test.xml. now i want to generate a html report out of it how do i do it ? MY project is complex and i cant do as a normal

<target name ="test" depends="run-tests">
    <junitreport todir="${reports}">
        <fileset dir="${reports}/raw/">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${reports}\html\"/>
    </junitreport>
</target>

anybody any tool that can be used to convert the results in xml to a html format.

like image 800
tharani dharan Avatar asked Dec 21 '11 12:12

tharani dharan


2 Answers

Given just the junit xml file (and python) you can convert the xml junit report file into a single self-contained HTML file using junit2html. https://github.com/inorton/junit2html

I had wanted a tool that does this for quite a long time so finally sat down the other day and had a go. It is pure python so should work on any platform as a stand-alone tool.

like image 133
IanNorton Avatar answered Nov 14 '22 23:11

IanNorton


Not 100% sure what you're asking but heck here's my ant code for doing a JUnit batch test then a HTML report using the XML formatter...

   <junit showoutput="on" printsummary="on" fork="false" haltonfailure="false"
    failureproperty="unittest.failure">
    <classpath>
      <pathelement path="${build.classpath}"/>
      <pathelement path="${classes}"/>
    </classpath>
    <batchtest todir="${unittests.results}">
      <fileset dir="${classes}">
        <include name="${batchtest.prefix}@{test}_test.class" />
      </fileset>
      <formatter type="xml"/>
    </batchtest>
  </junit>
  <junitreport todir="${unittests.results}">
    <fileset dir="${unittests.results}"/>
    <report todir="${unittests.results}"/>
  </junitreport>

note that the @{test} is because its part of a macrodef within the build.xml file.

From what you said in the question, its unsure if you're using the <formatter type="xml">.

Anyway hope that helps

oh and dont mix your slashes ${reports}\html\" > ${reports}/html/"

like image 37
Josh England Avatar answered Nov 14 '22 23:11

Josh England