开发者

Adding a stylesheet declaration to ci_reporter xml files automatically

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 T开发者_StackOverflow中文版est/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?


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.


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'}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜