This post originated from an RSS feed registered with Agile Buzz
by Jared Richardson.
Original Post: Run your Ruby Test and Get JUnit HTML or XML
Feed Title: Jared's Weblog
Feed URL: http://www.jaredrichardson.net/blog/index.rss
Feed Description: Jared's weblog.
The web site was created after the launch of the book "Ship It!" and discusses issues from Continuous Integration to web hosting providers.
This is a problem I've needed resolved for a while, and others on the Cruise Control mailing list have also asked about it. But thanks to the hard work of Alexey Verkhovsky, the problem appears to be solved.
There isn't a mature Continuous Integration solution available for Ruby and Rails projects, so we wrap our Rake scripts in Ant scripts and run them from Cruise Control. This isn't an ideal solution because the Ant script only sees a binary pass or fail for the entire suite. It doesn't know about the 137 tests you ran with 7,014 asserts. It just sees that everything passed or something failed. In order for Cruise Control to properly report on the test results, you need a JUnit formatted XML file.
Last night at our local Ruby Meetup, I asked Nathaniel Talbot (the guy who wrote Test::Unit) what he thought about using AspectR to solve this problem, and Nathaniel pointed me to this new project, Test/Unit Report.
It's a new project, and it had a few wrinkles. I've sent mail to Alex, but if you want to get started today, here's what I had to do.
In reporter.rb (located in /usr/local/lib/ruby/site_ruby/1.8/test/unit/ui on my box), I had to add
require 'test/unit/ui/console/testrunner'
And in the documentation, anything that refers to ui/reporter/reporter should be ui/reporter
For instance, require 'test/unit/ui/reporter/reporter' should be require 'test/unit/ui/reporter''
Given that this is a brand new project, these are minor bumps in the road for a nice JUnit log file for my Ruby automated tests. I suspect by the time you read this and try it out yourself, these problems will all be solved.