test-unit 3.2.5 → 3.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/BSDL +24 -0
  3. data/COPYING +41 -44
  4. data/README.md +8 -11
  5. data/Rakefile +0 -23
  6. data/doc/text/getting-started.md +1 -1
  7. data/doc/text/news.md +366 -0
  8. data/lib/test/unit/assertion-failed-error.rb +35 -0
  9. data/lib/test/unit/assertions.rb +312 -112
  10. data/lib/test/unit/attribute.rb +7 -2
  11. data/lib/test/unit/autorunner.rb +79 -31
  12. data/lib/test/unit/code-snippet-fetcher.rb +7 -7
  13. data/lib/test/unit/collector/descendant.rb +1 -0
  14. data/lib/test/unit/collector/dir.rb +4 -2
  15. data/lib/test/unit/collector/load.rb +10 -13
  16. data/lib/test/unit/collector/objectspace.rb +1 -0
  17. data/lib/test/unit/collector.rb +31 -0
  18. data/lib/test/unit/color-scheme.rb +20 -2
  19. data/lib/test/unit/data-sets.rb +116 -0
  20. data/lib/test/unit/data.rb +121 -12
  21. data/lib/test/unit/diff.rb +2 -3
  22. data/lib/test/unit/fixture.rb +6 -0
  23. data/lib/test/unit/notification.rb +9 -7
  24. data/lib/test/unit/omission.rb +34 -31
  25. data/lib/test/unit/pending.rb +12 -11
  26. data/lib/test/unit/priority.rb +7 -3
  27. data/lib/test/unit/runner/console.rb +8 -0
  28. data/lib/test/unit/test-suite-creator.rb +22 -8
  29. data/lib/test/unit/testcase.rb +216 -146
  30. data/lib/test/unit/testsuite.rb +1 -1
  31. data/lib/test/unit/ui/console/testrunner.rb +92 -32
  32. data/lib/test/unit/util/memory-usage.rb +47 -0
  33. data/lib/test/unit/util/observable.rb +2 -2
  34. data/lib/test/unit/util/output.rb +5 -4
  35. data/lib/test/unit/util/procwrapper.rb +4 -4
  36. data/lib/test/unit/version.rb +1 -1
  37. data/lib/test/unit/warning.rb +3 -0
  38. data/lib/test/unit.rb +177 -161
  39. data/lib/test-unit.rb +2 -17
  40. metadata +13 -88
  41. data/GPL +0 -339
  42. data/LGPL +0 -502
  43. data/test/collector/test-descendant.rb +0 -182
  44. data/test/collector/test-load.rb +0 -442
  45. data/test/collector/test_dir.rb +0 -407
  46. data/test/collector/test_objectspace.rb +0 -102
  47. data/test/fixtures/header-label.csv +0 -3
  48. data/test/fixtures/header-label.tsv +0 -3
  49. data/test/fixtures/header.csv +0 -3
  50. data/test/fixtures/header.tsv +0 -3
  51. data/test/fixtures/no-header.csv +0 -2
  52. data/test/fixtures/no-header.tsv +0 -2
  53. data/test/fixtures/plus.csv +0 -3
  54. data/test/run-test.rb +0 -22
  55. data/test/test-assertions.rb +0 -2180
  56. data/test/test-attribute-matcher.rb +0 -38
  57. data/test/test-attribute.rb +0 -123
  58. data/test/test-code-snippet.rb +0 -37
  59. data/test/test-color-scheme.rb +0 -82
  60. data/test/test-color.rb +0 -47
  61. data/test/test-data.rb +0 -303
  62. data/test/test-diff.rb +0 -518
  63. data/test/test-emacs-runner.rb +0 -60
  64. data/test/test-error.rb +0 -26
  65. data/test/test-failure.rb +0 -33
  66. data/test/test-fault-location-detector.rb +0 -163
  67. data/test/test-fixture.rb +0 -713
  68. data/test/test-notification.rb +0 -33
  69. data/test/test-omission.rb +0 -81
  70. data/test/test-pending.rb +0 -70
  71. data/test/test-priority.rb +0 -173
  72. data/test/test-test-case.rb +0 -1278
  73. data/test/test-test-result.rb +0 -113
  74. data/test/test-test-suite-creator.rb +0 -97
  75. data/test/test-test-suite.rb +0 -151
  76. data/test/testunit-test-util.rb +0 -31
  77. data/test/ui/test_testrunmediator.rb +0 -20
  78. data/test/util/test-method-owner-finder.rb +0 -38
  79. data/test/util/test-output.rb +0 -11
  80. data/test/util/test_backtracefilter.rb +0 -52
  81. data/test/util/test_observable.rb +0 -102
  82. data/test/util/test_procwrapper.rb +0 -36
@@ -1,33 +0,0 @@
1
- require 'test/unit'
2
- require 'testunit-test-util'
3
-
4
- class TestUnitNotification < Test::Unit::TestCase
5
- include TestUnitTestUtil
6
-
7
- class TestCase < Test::Unit::TestCase
8
- class << self
9
- def suite
10
- Test::Unit::TestSuite.new(name)
11
- end
12
- end
13
-
14
- def test_notify
15
- notify("1st notify")
16
- notify("2nd notify. Reach here.")
17
- end
18
- end
19
-
20
- def test_notify
21
- result = _run_test("test_notify")
22
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
23
- "0 omissions, 2 notifications",
24
- result.to_s)
25
- assert_fault_messages(["1st notify", "2nd notify. Reach here."],
26
- result.notifications)
27
- end
28
-
29
- private
30
- def _run_test(name)
31
- super(TestCase, name)
32
- end
33
- end
@@ -1,81 +0,0 @@
1
- require 'test/unit'
2
- require 'testunit-test-util'
3
-
4
- class TestUnitOmission < Test::Unit::TestCase
5
- include TestUnitTestUtil
6
-
7
- class TestCase < Test::Unit::TestCase
8
- class << self
9
- def suite
10
- Test::Unit::TestSuite.new(name)
11
- end
12
- end
13
-
14
- def test_omit
15
- omit("1st omit")
16
- omit("2nd omit. Should not be reached here.")
17
- assert(true, "Should not be reached here too.")
18
- end
19
-
20
- def test_omit_with_condition
21
- omit_if(false, "Never omit.")
22
- omit_unless(true, "Never omit too.")
23
- omit_if(true, "Should omit.")
24
- omit("The last omit. Should not be reached here.")
25
- end
26
-
27
- def test_omit_with_block
28
- omit("Omit block") do
29
- flunk("Should not be reached here.")
30
- end
31
- assert(true, "Should be reached here.")
32
- end
33
-
34
- def test_omit_with_block_and_condition
35
- omit_if(false, "Never omit.") do
36
- assert(true, "Should be reached here.")
37
- end
38
- omit_if(true, "Should omit.") do
39
- flunk("Never reached here.")
40
- end
41
- assert(true, "Should be reached here too.")
42
- end
43
- end
44
-
45
- def test_omit
46
- result = _run_test("test_omit")
47
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
48
- "1 omissions, 0 notifications",
49
- result.to_s)
50
- assert_fault_messages(["1st omit"], result.omissions)
51
- end
52
-
53
- def test_omit_with_condition
54
- result = _run_test("test_omit_with_condition")
55
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
56
- "1 omissions, 0 notifications",
57
- result.to_s)
58
- assert_fault_messages(["Should omit."], result.omissions)
59
- end
60
-
61
- def test_omit_with_block
62
- result = _run_test("test_omit_with_block")
63
- assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, " \
64
- "1 omissions, 0 notifications",
65
- result.to_s)
66
- assert_fault_messages(["Omit block"], result.omissions)
67
- end
68
-
69
- def test_omit_with_condition_and_block
70
- result = _run_test("test_omit_with_block_and_condition")
71
- assert_equal("1 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, " \
72
- "1 omissions, 0 notifications",
73
- result.to_s)
74
- assert_fault_messages(["Should omit."], result.omissions)
75
- end
76
-
77
- private
78
- def _run_test(name)
79
- super(TestCase, name)
80
- end
81
- end
data/test/test-pending.rb DELETED
@@ -1,70 +0,0 @@
1
- require 'test/unit'
2
- require 'testunit-test-util'
3
-
4
- class TestUnitPending < Test::Unit::TestCase
5
- include TestUnitTestUtil
6
-
7
- class TestCase < Test::Unit::TestCase
8
- class << self
9
- def suite
10
- Test::Unit::TestSuite.new(name)
11
- end
12
- end
13
-
14
- def test_pend
15
- pend("1st pend")
16
- pend("2nd pend. Should not be reached here.")
17
- assert(true, "Should not be reached here too.")
18
- end
19
-
20
- def test_pend_with_failure_in_block
21
- pend("Wait a minute") do
22
- raise "Not implemented yet"
23
- end
24
- assert(true, "Reached here.")
25
- end
26
-
27
- def test_pend_with_no_failure_in_block
28
- pend("Wait a minute") do
29
- "Nothing raised"
30
- end
31
- assert(true, "Not reached here.")
32
- end
33
- end
34
-
35
- def test_pend
36
- test = nil
37
- result = _run_test("test_pend") {|t| test = t}
38
- assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 1 pendings, " \
39
- "0 omissions, 0 notifications",
40
- result.to_s)
41
- assert_fault_messages(["1st pend"], result.pendings)
42
- assert_true(test.interrupted?)
43
- end
44
-
45
- def test_pend_with_failure_in_block
46
- test = nil
47
- result = _run_test("test_pend_with_failure_in_block") {|t| test = t}
48
- assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 1 pendings, " \
49
- "0 omissions, 0 notifications",
50
- result.to_s)
51
- assert_fault_messages(["Wait a minute"], result.pendings)
52
- assert_false(test.interrupted?)
53
- end
54
-
55
- def test_pend_with_no_failure_in_block
56
- test = nil
57
- result = _run_test("test_pend_with_no_failure_in_block") {|t| test = t}
58
- assert_equal("1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, " \
59
- "0 omissions, 0 notifications",
60
- result.to_s)
61
- assert_fault_messages(["Pending block should not be passed: Wait a minute."],
62
- result.failures)
63
- assert_true(test.interrupted?)
64
- end
65
-
66
- private
67
- def _run_test(name, &block)
68
- super(TestCase, name, &block)
69
- end
70
- end
@@ -1,173 +0,0 @@
1
- require 'test/unit'
2
-
3
- class TestUnitPriority < Test::Unit::TestCase
4
- class TestCase < Test::Unit::TestCase
5
- class << self
6
- def suite
7
- Test::Unit::TestSuite.new(name)
8
- end
9
- end
10
-
11
- priority :must
12
- def test_must
13
- assert(true)
14
- end
15
-
16
- def test_must_inherited
17
- assert(true)
18
- end
19
-
20
- priority :important
21
- def test_important
22
- assert(true)
23
- end
24
-
25
- def test_important_inherited
26
- assert(true)
27
- end
28
-
29
- priority :high
30
- def test_high
31
- assert(true)
32
- end
33
-
34
- def test_high_inherited
35
- assert(true)
36
- end
37
-
38
- priority :normal
39
- def test_normal
40
- assert(true)
41
- end
42
-
43
- def test_normal_inherited
44
- assert(true)
45
- end
46
-
47
- priority :low
48
- def test_low
49
- assert(true)
50
- end
51
-
52
- def test_low_inherited
53
- assert(true)
54
- end
55
-
56
- priority :never
57
- def test_never
58
- assert(true)
59
- end
60
-
61
- def test_never_inherited
62
- assert(true)
63
- end
64
- end
65
-
66
- def test_priority_must
67
- assert_priority("must", 1.0, 0.0001)
68
- end
69
-
70
- def test_priority_important
71
- assert_priority("important", 0.9, 0.09)
72
- end
73
-
74
- def test_priority_high
75
- assert_priority("high", 0.70, 0.1)
76
- end
77
-
78
- def test_priority_normal
79
- assert_priority("normal", 0.5, 0.1)
80
- end
81
-
82
- def test_priority_low
83
- assert_priority("low", 0.25, 0.1)
84
- end
85
-
86
- def test_priority_never
87
- assert_priority("never", 0.0, 0.0001)
88
- end
89
-
90
- def assert_priority(priority, expected, delta)
91
- assert_need_to_run("test_#{priority}", expected, delta)
92
- assert_need_to_run("test_#{priority}_inherited", expected, delta)
93
- end
94
-
95
- def assert_need_to_run(test_name, expected, delta)
96
- test = TestCase.new(test_name)
97
- n = 1000
98
- n_need_to_run = 0
99
- n.times do |i|
100
- n_need_to_run += 1 if Test::Unit::Priority::Checker.need_to_run?(test)
101
- end
102
- assert_in_delta(expected, n_need_to_run.to_f / n, delta)
103
- end
104
-
105
- class TestClassName < self
106
- def test_colon
107
- assert_escaped_name("Test__Priority", "Test::Priority")
108
- end
109
-
110
- def test_space
111
- assert_escaped_name("test_priority", "test priority")
112
- end
113
-
114
- def test_slash
115
- assert_escaped_name("test_priority", "test/priority")
116
- end
117
-
118
- def test_back_slash
119
- assert_escaped_name("test_priority", "test\/priority")
120
- end
121
-
122
- def assert_escaped_name(expected, class_name)
123
- checker = Checker.new(nil)
124
- escaped_class_name = checker.send(:escape_class_name, class_name)
125
- assert_equal(expected, escaped_class_name)
126
- end
127
- end
128
-
129
- class TestFileName < self
130
- class SpecialNameTestCase < Test::Unit::TestCase
131
- class << self
132
- def suite
133
- Test::Unit::TestSuite.new(name)
134
- end
135
- end
136
-
137
- def test_question?
138
- end
139
-
140
- def test_exclamation!
141
- end
142
-
143
- def test_equal=
144
- end
145
-
146
- test "have space" do
147
- end
148
- end
149
-
150
- def test_question
151
- assert_escaped_name("test_question.predicate", "test_question?")
152
- end
153
-
154
- def test_exclamation
155
- assert_escaped_name("test_exclamation.destructive", "test_exclamation!")
156
- end
157
-
158
- def test_equal
159
- assert_escaped_name("test_equal.equal", "test_equal=")
160
- end
161
-
162
- def test_colon_and_space
163
- assert_escaped_name("test_colon__have_space", "test: have space")
164
- end
165
-
166
- def assert_escaped_name(expected, test_method_name)
167
- checker = Checker.new(SpecialNameTestCase.new(test_method_name))
168
- passed_file = checker.send(:passed_file)
169
- method_name_component = File.basename(File.dirname(passed_file))
170
- assert_equal(expected, method_name_component)
171
- end
172
- end
173
- end