Wednesday, October 23, 2013

Convert TestNG/JUnit XML to HTML reports

Create a DIR for you report in the dir where this is (Or change path)
Place this where your XML is (Or change path)

<project name="TestNG_WORKSPACE" default="junit-report" basedir=".">
  <!-- Sets the property variables to point to respective directories -->
  <property name="junit-xml-dir" value="./"/>
  <property name="report-dir" value="./ChatReport/" />

  <!-- Ant target to generate html report -->
  <target name="junit-report">
    <!-- Delete and recreate the html report directories -->
    <delete dir="${report-dir}" failonerror="false"/>
    <mkdir dir="${report-dir}" />
    <mkdir dir="${report-dir}/Html" />
    <!-- Ant task to generate the html report.
    todir - Directory to generate the output reports

    fileset - Directory to look for the junit xml reports.

    report - defines the type of format to be generated.
      Here we are using "noframes" which generates a single html report.
     -->
    <junitreport todir="${report-dir}/Html">
      <fileset dir="${junit-xml-dir}">
        <include name="**/*.xml" />
      </fileset>
      <report format="noframes" todir="${report-dir}/Html" />
    </junitreport>
  </target>
</project>

It will generate the html reports under value="./ChatReport/Html

~joviano_dias@hotmail.com

1 comment:

  1. Hi,

    I have a few questions regarding Convert TestNG/JUnit XML to HTML reports

    1) In what format i need to save the above code you had written
    2) How to run the code after saving the code in the said format?Is this should be run through jenkins,if so where do we need to place the code file

    regards
    shiva narayan

    ReplyDelete