2011-06-12 118 views

回答

1

如何改变assert_equal(或者你使用的任何断言)呢?

require 'test/unit' 

class Test::Unit::TestCase 
    def assert_equal(expected, got, msg) 
    begin 
     super(expected, got, msg) 
    rescue 
     p "caught ya!" # make screenshot here 
     raise 
    end 
    end 
end 

class DemoTest < Test::Unit::TestCase 

    def test_fail 
    assert_equal(1, 0, 'ups') 
    end 
end 
+0

谢谢,这可能是一个可行的解决方案,因为我主要在我的测试中使用assert和assert_equal。 – 2011-06-13 07:32:31