Skip to content

Instantly share code, notes, and snippets.

@olore
Created June 8, 2011 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olore/1013701 to your computer and use it in GitHub Desktop.
Save olore/1013701 to your computer and use it in GitHub Desktop.
overriding TestCase in start towards getting html output report
require "test/unit"
module WatirReporting
def self.included(klass)
klass.class_eval do
alias_method(:add_failure_orig, :add_failure)
alias_method(:add_error_orig, :add_error)
alias_method(:teardown_orig, :teardown)
def add_failure(message, backtrace)
puts "FAIL: #{@method_name} - we had a failure!"
add_failure_orig(message, backtrace)
end
def add_error(error)
puts "ERROR: #{@method_name} - we had an error!"
add_error_orig(error)
end
def teardown #watir_teardown
puts "SUCCESS: #{@method_name}" if passed?
puts "Running test teardown"
teardown_orig #I dont think this is necessary
end
end
end
end
class Test::Unit::TestCase
include WatirReporting
end
class BookTest < Test::Unit::TestCase
def setup
#puts "add_failure_orig: #{self.method(:add_failure_orig).object_id}"
#puts "add_failure: #{self.method(:add_failure).object_id}"
end
def teardown
#puts "BookTest teardown" #just do something in teardown
#is there a way to force super?
super
end
def test_fail
assert nil
end
def test_pass
assert true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment