使用Ruby测试/单元拆卸方法检查​​测试结果

| 是否可以使用拆解方法检查Ruby测试/单元的结果? 我正在将Ruby与Test / Unit,WATIR和Webdriver一起使用,以测试Web应用程序,如果测试失败,我想在拆卸方法中截取屏幕截图。     
已邀请:
        改为更改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
    

要回复问题请先登录注册