Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in DevOps and Agile by (19.7k points)

Is there a way to (easily) generate an HTML report that contains the results of the test? I am currently using JUnit in addition to Selenium for testing web apps UI.

PS: Given the project structure I am not supposed to use Ant sad

1 Answer

0 votes
by (62.9k points)

 You can easily do this via ant. Here is a build.xml file for doing this

 <project name="genTestReport" default="gen" basedir=".">

        <description>

                Generate the HTML report from JUnit XML files

        </description>

 

        <target name="gen">

                <property name="genReportDir" location="${basedir}/unitTestReports"/>

                <delete dir="${genReportDir}"/>

                <mkdir dir="${genReportDir}"/>

                <junitreport todir="${basedir}/unitTestReports">

                        <fileset dir="${basedir}">

                                <include name="**/TEST-*.xml"/>

                        </fileset>

                        <report format="frames" todir="${genReportDir}/html"/>

                </junitreport>

        </target>

</project>

This will identify the files with the format TEST-*.xml and create a test report with results into a folder named unitTestReports.

To run this (say the name of the above file is createTestReports.xml) run the following command in the terminal:

ant -buildfile createTestReports.xml

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...