test-unit/test/test-testcase.rb in activegroonga-0.0.7 vs test-unit/test/test-testcase.rb in activegroonga-1.0.0
- old
+ new
@@ -5,10 +5,11 @@
require 'test/unit'
module Test
module Unit
class TestTestCase < TestCase
+ self.test_order = :random
def test_creation
tc = Class.new(TestCase) do
def test_with_arguments(arg1, arg2)
end
end
@@ -467,41 +468,77 @@
test_case.new("test_fail")
end
end
def test_defined_order
- keep_test_order do
- test_case = Class.new(Test::Unit::TestCase) do
- def test_z
- end
+ test_case = Class.new(Test::Unit::TestCase) do
+ def test_z
+ end
- def test_1
- end
+ def test_1
+ end
- def test_a
- end
+ def test_a
end
+ end
- assert_equal(["test_1", "test_a", "test_z"],
- test_case.suite.tests.collect {|test| test.method_name})
+ assert_equal(["test_1", "test_a", "test_z"],
+ test_case.suite.tests.collect {|test| test.method_name})
- test_case.test_order = :defined
- assert_equal(["test_z", "test_1", "test_a"],
- test_case.suite.tests.collect {|test| test.method_name})
+ test_case.test_order = :defined
+ assert_equal(["test_z", "test_1", "test_a"],
+ test_case.suite.tests.collect {|test| test.method_name})
+ end
+
+ def test_declarative_style
+ test_case = Class.new(Test::Unit::TestCase) do
+ test "declarative style test definition" do
+ end
+
+ test "include parenthesis" do
+ end
+
+ test "1 + 2 = 3" do
+ end
end
+
+ test_case.test_order = :defined
+
+ assert_equal(["test_declarative_style_test_definition",
+ "test_include_parenthesis",
+ "test_1_2_3"],
+ test_case.suite.tests.collect {|test| test.method_name})
+
+ assert_equal(["declarative style test definition",
+ "include parenthesis",
+ "1 + 2 = 3"],
+ test_case.suite.tests.collect {|test| test.description})
end
+ def test_redefine_method
+ test_case = Class.new(Test::Unit::TestCase) do
+ def test_name
+ end
+ alias_method :test_name2, :test_name
+
+ def test_name
+ end
+ end
+
+ suite = test_case.suite
+ assert_equal(["test_name", "test_name2"],
+ suite.tests.collect {|test| test.method_name})
+ result = TestResult.new
+ suite.run(result) {}
+ assert_equal("2 tests, 0 assertions, 0 failures, " +
+ "0 errors, 0 pendings, 0 omissions, 1 notifications",
+ result.summary)
+ end
+
private
def check(message, passed)
add_assertion
raise AssertionFailedError.new(message) unless passed
- end
-
- def keep_test_order
- order = TestCase.test_order
- yield
- ensure
- TestCase.test_order = order
end
end
end
end