Created
June 8, 2011 03:09
-
-
Save olore/1013701 to your computer and use it in GitHub Desktop.
overriding TestCase in start towards getting html output report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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