There are ci_reporter gem which generates xml reports, but we required HTML reports. There are various XSL files available on internet which we can use to generate HTML reports out of this XML, I tried that but the reports were not good. We wanted something like generated through ReportNG or Junit.
So I did the trick, I generated JUnit HTML reports from this WATIR XML report file using junitreport ANT Task.
So let's see how to do it.
First you need to install ci_reporter. use the following command to install it.
gem install ci_reporter
require 'test/unit/testcase' require 'rubygems' require 'funfx' require 'ci/reporter/rake/test_unit_loader.rb' class Demo < Test::Unit::TestCase def test_first assert(true,"PASS"); end def test_second assert(false,"Fail"); end endWhen you will run the above code it will generate the XML report under test\report folder. Now to generate the HTML report from this XML file, save the following file as build.xml where your above test file is located.
<project name="Report" default="generateReport" basedir="."> <property name="report.dir" value="test\reports" /> <target name="generateReport"> <junitreport todir="${report.dir}"> <fileset dir="${report.dir}"> <include name="*.xml" /> </fileset> <report format="noframes" todir="${report.dir}" /> </junitreport> </target> </project>
Now run the following command from command line.
ANT
But before you run this command ANT need to be installed on your system. Download and install the ANT from following location.
http://ant.apache.org/bindownload.cgi
Following is the screenshot of report.
0 comments:
Post a Comment