Reputation: 1856
Is it possible to check the result of a Ruby Test/Unit in the teardown method?
I am using Ruby with Test/Unit, WATIR and Webdriver to test a web application and would like to grab a screenshot in the teardown method if the test has failed.
Upvotes: 2
Views: 663
Reputation: 30815
How about changing assert_equal (or whatever assertion you're using) instead?
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
Upvotes: 1