diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/minitest/test_mini_spec.rb | 3 | ||||
-rw-r--r-- | test/minitest/test_mini_test.rb | 81 |
2 files changed, 44 insertions, 40 deletions
diff --git a/test/minitest/test_mini_spec.rb b/test/minitest/test_mini_spec.rb index 89c552308f..f80310c4d1 100644 --- a/test/minitest/test_mini_spec.rb +++ b/test/minitest/test_mini_spec.rb @@ -17,6 +17,9 @@ describe MiniTest::Spec do self._assertions.must_equal @assertion_count end + # TODO: figure out how the hell to write a test for this + # it "will skip if there is no block" + it "needs to have all methods named well" do @assertion_count = 2 diff --git a/test/minitest/test_mini_test.rb b/test/minitest/test_mini_test.rb index f4c519ac9a..7ceb4f3c06 100644 --- a/test/minitest/test_mini_test.rb +++ b/test/minitest/test_mini_test.rb @@ -207,7 +207,7 @@ class TestMiniTest < MiniTest::Unit::TestCase Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started @@ -219,6 +219,8 @@ test_failure(ATestCase) [FILE:LINE]: Failed assertion, no message given. 2 tests, 2 assertions, 1 failures, 0 errors, 0 skips + +Test run options: --seed 42 " util_assert_report expected end @@ -236,7 +238,7 @@ Failed assertion, no message given. Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started @@ -249,6 +251,8 @@ RuntimeError: unhandled exception FILE:LINE:in `test_error' 2 tests, 1 assertions, 0 failures, 1 errors, 0 skips + +Test run options: --seed 42 " util_assert_report expected end @@ -266,7 +270,7 @@ RuntimeError: unhandled exception Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started @@ -279,6 +283,8 @@ RuntimeError: unhandled exception FILE:LINE:in `teardown' 1 tests, 1 assertions, 0 failures, 1 errors, 0 skips + +Test run options: --seed 42 " util_assert_report expected end @@ -296,7 +302,7 @@ RuntimeError: unhandled exception Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started @@ -308,6 +314,8 @@ test_skip(ATestCase) [FILE:LINE]: not yet 2 tests, 1 assertions, 0 failures, 0 errors, 1 skips + +Test run options: --seed 42 " util_assert_report expected end @@ -319,6 +327,8 @@ Started Finished in 0.00 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips + +Test run options: --seed 42 " output = @output.string.sub(/Finished in .*/, "Finished in 0.00") output.sub!(/Loaded suite .*/, 'Loaded suite blah') @@ -340,9 +350,18 @@ Finished in 0.00 Object.const_set(:ATestCase, tc) - @tu.run(%w(-n /something/)) + @tu.run %w[-n /something/ -s 42] - util_assert_report + expected = "Loaded suite blah +Started +. +Finished in 0.00 + +1 tests, 1 assertions, 0 failures, 0 errors, 0 skips + +Test run options: --seed 42 --name \"/something/\" +" + util_assert_report expected end def test_run_passing @@ -354,7 +373,7 @@ Finished in 0.00 Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] util_assert_report end @@ -703,14 +722,14 @@ FILE:LINE:in `test_assert_raises_triggered_subclass' def test_assert_same_triggered @assertion_count = 2 - util_assert_triggered 'Expected 2 (0xXXX) to be the same as 1 (0xXXX).' do + util_assert_triggered 'Expected 2 (oid=N) to be the same as 1 (oid=N).' do @tc.assert_same 1, 2 end s1 = "blah" s2 = "blah" - util_assert_triggered 'Expected "blah" (0xXXX) to be the same as "blah" (0xXXX).' do + util_assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do @tc.assert_same s1, s2 end end @@ -786,16 +805,11 @@ FILE:LINE:in `test_assert_raises_triggered_subclass' def test_test_methods_sorted @assertion_count = 0 - sample_test_case = Class.new(MiniTest::Unit::TestCase) - - class << sample_test_case - def test_order; :sorted end - end - - sample_test_case.instance_eval do - define_method :test_test3 do assert "does not matter" end - define_method :test_test2 do assert "does not matter" end - define_method :test_test1 do assert "does not matter" end + sample_test_case = Class.new(MiniTest::Unit::TestCase) do + def self.test_order; :sorted end + def test_test3; assert "does not matter" end + def test_test2; assert "does not matter" end + def test_test1; assert "does not matter" end end expected = %w(test_test1 test_test2 test_test3) @@ -805,27 +819,15 @@ FILE:LINE:in `test_assert_raises_triggered_subclass' def test_test_methods_random @assertion_count = 0 - sample_test_case = Class.new(MiniTest::Unit::TestCase) - - class << sample_test_case - def test_order; :random end + sample_test_case = Class.new(MiniTest::Unit::TestCase) do + def test_test1; assert "does not matter" end + def test_test2; assert "does not matter" end + def test_test3; assert "does not matter" end end - sample_test_case.instance_eval do - define_method :test_test1 do assert "does not matter" end - define_method :test_test2 do assert "does not matter" end - define_method :test_test3 do assert "does not matter" end - end - - srand 42 - expected = %w(test_test1 test_test2 test_test3) - max = expected.size - expected = expected.sort_by { rand(max) } - srand 42 - result = sample_test_case.test_methods - - assert_equal expected, result + expected = %w(test_test2 test_test1 test_test3) + assert_equal expected, sample_test_case.test_methods end def test_refute @@ -991,9 +993,8 @@ FILE:LINE:in `test_assert_raises_triggered_subclass' @tc.refute_same 1, 2 end - # TODO: "with id <id>" crap from assertions.rb def test_refute_same_triggered - util_assert_triggered 'Expected 1 to not be the same as 1.' do + util_assert_triggered 'Expected 1 (oid=N) to not be the same as 1 (oid=N).' do @tc.refute_same 1, 1 end end @@ -1012,7 +1013,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass' end msg = e.message.sub(/(---Backtrace---).*/m, '\1') - msg.gsub!(/\(0x[0-9a-f]+\)/, '(0xXXX)') + msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)') assert_equal expected, msg end |