Permalink
Browse files

+ Errors in teardown are now recorded. (randycoulman)

[git-p4: depot-paths = "//src/minitest/dev/": change = 8111]
  • Loading branch information...
1 parent 86c3ce2 commit c4a4d929a1a1851b5dc84a6a919248671d1a2e05 @zenspider zenspider committed Jan 15, 2013
Showing with 84 additions and 0 deletions.
  1. +1 −0 .autotest
  2. +1 −0 lib/minitest/unit.rb
  3. +82 −0 test/minitest/test_minitest_unit.rb
View
@@ -10,6 +10,7 @@ Autotest.add_hook :initialize do |at|
at.extra_class_map["TestMeta"] = "test/test_minitest_spec.rb"
at.extra_class_map["TestMiniTestUnitTestCase"] = "test/test_minitest_unit.rb"
at.extra_class_map["TestMiniTestUnit"] = "test/test_minitest_unit.rb"
+ at.extra_class_map["TestMiniTestUnitRecording"]= "test/test_minitest_unit.rb"
at.extra_class_map["TestMiniTestStub"] = "test/test_minitest_mock.rb"
at.add_exception 'coverage.info'
at.add_exception 'coverage'
View
@@ -1315,6 +1315,7 @@ def run runner
raise
rescue Exception => e
@passed = false
+ runner.record self.class, self.__name__, self._assertions, time, e
result = runner.puke self.class, self.__name__, e
end
end
@@ -1742,3 +1742,85 @@ def test_windows_eh
assert self.windows? "mswin"
end
end
+
+class TestMiniTestUnitRecording < MetaMetaMetaTestCase
+ # do not parallelize this suite... it just can't handle it.
+
+ def assert_run_record(*expected, &block)
+ def @tu.record suite, method, assertions, time, error
+ recording[method] << error
+ end
+
+ def @tu.recording
+ @recording ||= Hash.new { |h,k| h[k] = [] }
+ end
+
+ MiniTest::Unit.runner = @tu
+
+ Class.new MiniTest::Unit::TestCase, &block
+
+ with_output do
+ @tu.run
+ end
+
+ recorded = @tu.recording.fetch("test_method").map(&:class)
+
+ assert_equal expected, recorded
+ end
+
+ def test_record_passing
+ assert_run_record NilClass do
+ def test_method
+ assert true
+ end
+ end
+ end
+
+ def test_record_failing
+ assert_run_record MiniTest::Assertion do
+ def test_method
+ assert false
+ end
+ end
+ end
+
+ def test_record_error
+ assert_run_record RuntimeError do
+ def test_method
+ raise "unhandled exception"
+ end
+ end
+ end
+
+ def test_record_error_teardown
+ assert_run_record NilClass, RuntimeError do
+ def test_method
+ assert true
+ end
+
+ def teardown
+ raise "unhandled exception"
+ end
+ end
+ end
+
+ def test_record_error_in_test_and_teardown
+ assert_run_record AnError, RuntimeError do
+ def test_method
+ raise AnError
+ end
+
+ def teardown
+ raise "unhandled exception"
+ end
+ end
+ end
+
+ def test_record_skip
+ assert_run_record MiniTest::Skip do
+ def test_method
+ skip "not yet"
+ end
+ end
+ end
+end

0 comments on commit c4a4d92

Please sign in to comment.