tags:

views:

36

answers:

2

Hey all,

I am not a programmer, so please be forgiving if my problem is fairly easy to solve for many of you (yet I still might find it confusing).

The problem I am having is with ci_reporter, a gem for use with Watir and Test/Unit.

It is outputting the test results from a Watir test to an xml file. Great so far. Unfortunately I cannot find a way to have ci_reporter add a xsl stylesheet declaration just after the xml declaration.

<?xml version="1.0" encoding="UTF-8"?>
<testsuite time="6.796" assertions="1" name="TC_LoginTests" failures="0" tests="1" skipped="0" errors="0">
  <testcase time="6.796" assertions="1" name="test_loginValid">
  </testcase>

What I want it to do is:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<testsuite time="6.796" assertions="1" name="TC_LoginTests" failures="0" tests="1" skipped="0" errors="0">
 <testcase time="6.796" assertions="1" name="test_loginValid">
 </testcase>

I thought perhaps there would be a parameter to set somewhere, but I have not found it if there is one. It will be quite tedious to add the stylesheet declaration manually each time.

Is there a simple solution to this problem?

A: 

Hi, I don't think you will be able to achieve what you want without hacking the source of ci_reporter. ci_reporter is designed to output JUnit format XML files, and doesn't offer any way to change this.

I would leave the XML output as it is, and then use something else to apply your xsl transformation as a secondary step.

edbrindley
This seems like the proper way of doing things, seeing as we are going to be using Hudson, but have not yet got Watir integrated with it. The other approach that you pointed me to still seems like an ok (if a bit dodgy) way of doing things if you are not yet using a tool like Hudson.
anonygoose
A: 

Turns out it's quite simple to do by altering the test_suite.rb file in the ci_reporter gem. Not sure how proper that is, but it gets it to do what I need it to.

In the to_xml method, we altered the following line:

builder.instruct!

to instead read

builder.instruct!
builder.instruct! 'xml-stylesheet', {:href=>'output.xsl', :type=>'text/xsl'}
anonygoose