test/test_mini_test.rb in minitest-1.5.0 vs test/test_mini_test.rb in minitest-1.6.0

- old
+ new

@@ -199,11 +199,11 @@ end end Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started F. Finished in 0.00 @@ -211,10 +211,12 @@ 1) Failure: 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 def test_run_error @@ -228,11 +230,11 @@ end end Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started E. Finished in 0.00 @@ -241,10 +243,12 @@ test_error(ATestCase): 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 def test_run_error_teardown @@ -258,11 +262,11 @@ end end Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started E Finished in 0.00 @@ -271,10 +275,12 @@ test_something(ATestCase): 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 def test_run_skip @@ -288,11 +294,11 @@ end end Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] expected = "Loaded suite blah Started S. Finished in 0.00 @@ -300,10 +306,12 @@ 1) Skipped: 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 def util_assert_report expected = nil @@ -311,10 +319,12 @@ 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') output.sub!(/^(\s+)(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+:/o, '\1FILE:LINE:') output.sub!(/\[(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+\]/o, '[FILE:LINE]') @@ -332,13 +342,22 @@ end end 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 tc = Class.new(MiniTest::Unit::TestCase) do def test_something @@ -346,11 +365,11 @@ end end Object.const_set(:ATestCase, tc) - @tu.run + @tu.run %w[-s 42] util_assert_report end end @@ -695,18 +714,18 @@ end 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 def test_assert_send @@ -778,50 +797,33 @@ end 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 + 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 - 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 - end - expected = %w(test_test1 test_test2 test_test3) assert_equal expected, sample_test_case.test_methods end 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 @assertion_count = 2 @@ -983,13 +985,12 @@ def test_refute_same @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 def test_skip @@ -1004,10 +1005,10 @@ e = assert_raises(klass) do yield 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 end