Timm Mason (c)
6/4/2008 1:54:00 AM
Hi, I was wondering if anyone has had any luck trying to extend
CI::Reporter
Specifically, I wanted to change some formatting, so that failure
messages are enclosed in CDATA blocks. I tried extending the to_xml
method in Rakefile.rb but it seems to have no effect, so clearly I am
missing something...
My Rakefile is below. When I run it, everything happens as if I haven't
actually extended the method at all. Ie "YO!!!" does not appear in the
XML output, and "this is broken!" never prints out. What am I missing
here?
require 'rake'
require 'rake/testtask'
require 'rake/clean'
require 'rubygems'
gem 'ci_reporter'
require 'ci/reporter/rake/test_unit'
require 'ci/reporter/core'
# modify ci_reporter to put failure message in CDATA element # note this
is not working class CI::Reporter::TestUnit
def to_xml(builder)
attrs =3D {}
each_pair {|k,v| attrs[k] =3D builder.trunc!(v.to_s)
unless v.nil? || v.to_s.empty?}
builder.testcase(attrs) do
failures.each do |failure|
builder.failure(:type =3D>
builder.trunc!(failure.name), :message =3D>
builder.trunc!(failure.message)) do
builder.text!("YO!!!" +
failure.message + " (#{failure.name})\n")
builder.text!(failure.location)
end
end
end
puts "this is broken!"
end
end
task :default =3D> [ :all_tests ]
task :all_tests =3D> ['ci:setup:testunit']
Rake::TestTask.new(:all_tests) do |t|
t.test_files =3D FileList['test/*test.rb']
t.verbose =3D true
t.warning =3D false
end