1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
require "test/unit"
module Test
module Unit
class TestTestSuiteCreator < TestCase
def collect_test_names(test_case)
creator = TestSuiteCreator.new(test_case)
creator.send(:collect_test_names)
end
class TestStandalone < self
def setup
@test_case = Class.new(TestCase) do
def test_in_test_case
end
end
end
def test_collect_test_names
assert_equal(["test_in_test_case"], collect_test_names(@test_case))
end
end
class TestInherited < self
def setup
@parent_test_case = Class.new(TestCase) do
def test_in_parent
end
end
@child_test_case = Class.new(@parent_test_case) do
def test_in_child
end
end
end
def test_collect_test_names
assert_equal(["test_in_child"], collect_test_names(@child_test_case))
end
end
class TestModule < self
def setup
test_module = Module.new do
def test_in_module
end
end
@test_case = Class.new(TestCase) do
include test_module
def test_in_test_case
end
end
end
def test_collect_test_names
assert_equal(["test_in_module", "test_in_test_case"].sort,
collect_test_names(@test_case).sort)
end
end
class TestInheritedModule < self
def setup
parent_test_module = Module.new do
def test_in_module_in_parent
end
end
child_test_module = Module.new do
def test_in_module_in_child
end
end
@parent_test_case = Class.new(TestCase) do
include parent_test_module
def test_in_parent
end
end
@child_test_case = Class.new(@parent_test_case) do
include child_test_module
def test_in_child
end
end
end
def test_collect_test_names
assert_equal(["test_in_child", "test_in_module_in_child"].sort,
collect_test_names(@child_test_case).sort)
end
end
end
end
end
|