Thursday, 24 January 2013

Generating a Junit Report for TestNG execution


Now a days everyone is using TestNG in place of Junit and as part of Selenium execution.


TestNg provides a lot of added features. One of the good thing it provides is test execution results in the form of XML. We can use this XML file for other type of report format generation. One of them is Junit reporting.
In this blog I will mention how to generate a Junit report for a TestNG execution.
Below ant target will generate the Junit report for the TestNG execution results.


?
1
2
3
4
5
6
7
8
9
10
11
12
<target name="junit-report">
<delete dir="${REPORT}/Junit"></delete>
        <mkdir dir="${REPORT}/Junit"></mkdir>
        <junitreport todir="${REPORT}/Junit">
            <fileset dir="${REPORT}/TestNG-report">
                <include name="*/*.xml">
           </include></fileset>
            <report format="noframes" todir="${REPORT}/Junit">
        </report>
</junitreport>
</target>
In the above ant target you need to specify the path to the TestNG results xml file in the "dir" attribute under the "fileset" tag.

You need to mention the path where you want to generate the Junit report in the "todir" attribute under the "report" tag.

Also you can mention whether you want the Junit report with frames or without frames in the "format" attribute under the "report" tag.

No comments:

Post a Comment