test-unit 1.2.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/History.txt +27 -0
  2. data/Manifest.txt +30 -8
  3. data/README.txt +9 -4
  4. data/Rakefile +16 -1
  5. data/bin/testrb +0 -0
  6. data/lib/test/unit/assertions.rb +148 -48
  7. data/lib/test/unit/attribute.rb +125 -0
  8. data/lib/test/unit/autorunner.rb +101 -71
  9. data/lib/test/unit/collector/descendant.rb +23 -0
  10. data/lib/test/unit/collector/dir.rb +1 -1
  11. data/lib/test/unit/collector/load.rb +135 -0
  12. data/lib/test/unit/color.rb +61 -0
  13. data/lib/test/unit/diff.rb +524 -0
  14. data/lib/test/unit/error.rb +70 -2
  15. data/lib/test/unit/exceptionhandler.rb +39 -0
  16. data/lib/test/unit/failure.rb +63 -4
  17. data/lib/test/unit/fixture.rb +185 -0
  18. data/lib/test/unit/notification.rb +125 -0
  19. data/lib/test/unit/omission.rb +143 -0
  20. data/lib/test/unit/pending.rb +146 -0
  21. data/lib/test/unit/priority.rb +146 -0
  22. data/lib/test/unit/runner/console.rb +46 -0
  23. data/lib/test/unit/runner/emacs.rb +8 -0
  24. data/lib/test/unit/testcase.rb +193 -76
  25. data/lib/test/unit/testresult.rb +37 -28
  26. data/lib/test/unit/testsuite.rb +35 -1
  27. data/lib/test/unit/ui/console/outputlevel.rb +14 -0
  28. data/lib/test/unit/ui/console/testrunner.rb +96 -28
  29. data/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  30. data/lib/test/unit/ui/testrunner.rb +20 -0
  31. data/lib/test/unit/ui/testrunnermediator.rb +28 -19
  32. data/lib/test/unit/ui/testrunnerutilities.rb +2 -7
  33. data/lib/test/unit/util/backtracefilter.rb +2 -1
  34. data/lib/test/unit/version.rb +1 -1
  35. data/test/collector/test_descendant.rb +135 -0
  36. data/test/collector/test_load.rb +333 -0
  37. data/test/run-test.rb +13 -0
  38. data/test/test_assertions.rb +221 -56
  39. data/test/test_attribute.rb +86 -0
  40. data/test/test_color.rb +37 -0
  41. data/test/test_diff.rb +477 -0
  42. data/test/test_emacs_runner.rb +60 -0
  43. data/test/test_fixture.rb +275 -0
  44. data/test/test_notification.rb +33 -0
  45. data/test/test_omission.rb +81 -0
  46. data/test/test_pending.rb +70 -0
  47. data/test/test_priority.rb +89 -0
  48. data/test/test_testcase.rb +160 -5
  49. data/test/test_testresult.rb +61 -52
  50. data/test/testunit_test_util.rb +14 -0
  51. data/test/ui/test_testrunmediator.rb +20 -0
  52. metadata +53 -23
  53. data/lib/test/unit/ui/fox/testrunner.rb +0 -268
  54. data/lib/test/unit/ui/gtk/testrunner.rb +0 -416
  55. data/lib/test/unit/ui/gtk2/testrunner.rb +0 -465
  56. data/lib/test/unit/ui/tk/testrunner.rb +0 -260
  57. data/test/runit/test_assert.rb +0 -402
  58. data/test/runit/test_testcase.rb +0 -91
  59. data/test/runit/test_testresult.rb +0 -144
  60. data/test/runit/test_testsuite.rb +0 -49
@@ -1,91 +0,0 @@
1
- # Author:: Masaki Suketa.
2
- # Adapted by:: Nathaniel Talbott.
3
- # Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
4
- # Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
5
- # License:: Ruby license.
6
-
7
- require 'rubyunit'
8
-
9
- module RUNIT
10
- class DummyError < StandardError
11
- end
12
-
13
- class TestTestCase < RUNIT::TestCase
14
- def setup
15
- @dummy_testcase = Class.new(RUNIT::TestCase) do
16
- def self.name
17
- "DummyTestCase"
18
- end
19
-
20
- attr_reader :status, :dummy_called, :dummy2_called
21
-
22
- def initialize(*arg)
23
- super(*arg)
24
- @status = 0
25
- @dummy_called = false
26
- @dummy2_called = false
27
- end
28
-
29
- def setup
30
- @status = 1 if @status == 0
31
- end
32
-
33
- def test_dummy
34
- @status = 2 if @status == 1
35
- @dummy_called = true
36
- end
37
-
38
- def test_dummy2
39
- @status = 2 if @status == 1
40
- @dummy2_called = true
41
- raise DummyError
42
- end
43
-
44
- def teardown
45
- @status = 3 if @status == 2
46
- end
47
- end
48
-
49
- @test1 = @dummy_testcase.new('test_dummy')
50
- @test2 = @dummy_testcase.new('test_dummy2', 'TestCase')
51
- end
52
-
53
- def test_name
54
- assert_equal('DummyTestCase#test_dummy', @test1.name) # The second parameter to #initialize is ignored in emulation
55
- assert_equal('DummyTestCase#test_dummy2', @test2.name)
56
- end
57
-
58
- def test_run
59
- result = RUNIT::TestResult.new
60
- @test1.run(result)
61
- assert_equal(1, result.run_count)
62
- end
63
-
64
- def test_s_suite
65
- suite = @dummy_testcase.suite
66
- assert_instance_of(RUNIT::TestSuite, suite)
67
- assert_equal(2, suite.count_test_cases)
68
- end
69
-
70
- def test_teardown_err
71
- suite = Class.new(RUNIT::TestCase) do
72
- def test_foo
73
- assert(false)
74
- end
75
-
76
- def test_bar
77
- assert(true)
78
- end
79
-
80
- def teardown
81
- raise StandardError
82
- end
83
- end.suite
84
-
85
- result = RUNIT::TestResult.new
86
- suite.run(result)
87
- assert_equal(2, result.error_size)
88
- assert_equal(1, result.failure_size)
89
- end
90
- end
91
- end
@@ -1,144 +0,0 @@
1
- # Author:: Masaki Suketa.
2
- # Adapted by:: Nathaniel Talbott.
3
- # Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
4
- # Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
5
- # License:: Ruby license.
6
-
7
- require 'rubyunit'
8
-
9
- module RUNIT
10
- class TestTestResult < RUNIT::TestCase
11
- def setup
12
- @result = RUNIT::TestResult.new
13
-
14
- @normal_suite = Class::new(RUNIT::TestCase) do
15
- def test_1
16
- assert(true)
17
- assert(true)
18
- end
19
- end.suite
20
-
21
- @failure_suite = Class::new(RUNIT::TestCase) do
22
- def test_1
23
- assert(true)
24
- assert(false)
25
- end
26
- end.suite
27
-
28
- @error_suite = Class::new(RUNIT::TestCase) do
29
- def setup
30
- raise ScriptError
31
- end
32
- def test_1
33
- assert(true)
34
- end
35
- end.suite
36
-
37
- @multi_failure_suite = Class::new(RUNIT::TestCase) do
38
- def test1
39
- assert(false)
40
- end
41
- def test2
42
- assert(false)
43
- end
44
- def test3
45
- assert(false)
46
- end
47
- end.suite
48
-
49
- @with_error_suite = Class::new(RUNIT::TestCase) do
50
- def test1
51
- raise StandardError
52
- end
53
- end.suite
54
-
55
- @multi_error_suite = Class::new(RUNIT::TestCase) do
56
- def test1
57
- raise StandardError
58
- end
59
- def test2
60
- raise StandardError
61
- end
62
- def test3
63
- raise StandardError
64
- end
65
- end.suite
66
-
67
- @multi_suite = Class::new(RUNIT::TestCase) do
68
- def test_1
69
- assert(true)
70
- assert(true)
71
- end
72
- def test_2
73
- assert(true)
74
- end
75
- def test_3
76
- assert(true)
77
- assert(false)
78
- assert(true)
79
- end
80
- end.suite
81
- end
82
-
83
- def test_error_size
84
- @normal_suite.run(@result)
85
- assert_equal(0, @result.error_size)
86
- @with_error_suite.run(@result)
87
- assert_equal(1, @result.error_size)
88
- @multi_error_suite.run(@result)
89
- assert_equal(4, @result.error_size)
90
- end
91
-
92
- def test_errors
93
- @normal_suite.run(@result)
94
- assert_equal(0, @result.errors.size)
95
- end
96
-
97
- def test_failure_size
98
- @normal_suite.run(@result)
99
- assert_equal(0, @result.failure_size)
100
- @failure_suite.run(@result)
101
- assert_equal(1, @result.failure_size)
102
- @multi_failure_suite.run(@result)
103
- assert_equal(4, @result.failure_size)
104
- end
105
-
106
- def test_failures
107
- @normal_suite.run(@result)
108
- assert_equal(0, @result.failures.size)
109
- @failure_suite.run(@result)
110
- assert_equal(1, @result.failures.size)
111
- @multi_failure_suite.run(@result)
112
- assert_equal(4, @result.failures.size)
113
- end
114
-
115
- def test_run_no_exception
116
- assert_no_exception {
117
- @error_suite.run(@result)
118
- }
119
- end
120
-
121
- def test_run_asserts
122
- @normal_suite.run(@result)
123
- assert_equal(2, @result.run_asserts)
124
- end
125
-
126
- def test_run_asserts2
127
- @failure_suite.run(@result)
128
- assert_equal(2, @result.run_asserts)
129
- end
130
-
131
- def test_run_tests
132
- assert_equal(0, @result.run_tests)
133
- @normal_suite.run(@result)
134
- assert_equal(1, @result.run_tests)
135
- @multi_suite.run(@result)
136
- assert_equal(4, @result.run_tests)
137
- end
138
-
139
- def test_succeed?
140
- @normal_suite.run(@result)
141
- assert(@result.succeed?)
142
- end
143
- end
144
- end
@@ -1,49 +0,0 @@
1
- # Author:: Masaki Suketa.
2
- # Adapted by:: Nathaniel Talbott.
3
- # Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
4
- # Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
5
- # License:: Ruby license.
6
-
7
- require 'rubyunit'
8
-
9
- module RUNIT
10
- class TestTestSuite < RUNIT::TestCase
11
- def setup
12
- @testsuite = RUNIT::TestSuite.new
13
- @dummy_test = Class.new(RUNIT::TestCase) do
14
- def test_foo
15
- end
16
- def test_bar
17
- end
18
- end
19
- @dummy_empty_test = Class.new(RUNIT::TestCase){}
20
- end
21
-
22
- def test_count_test_cases
23
- assert_equal(0, @testsuite.count_test_cases)
24
-
25
- @testsuite.add(@dummy_empty_test.suite)
26
- assert_equal(0, @testsuite.count_test_cases)
27
-
28
- @testsuite.add(@dummy_test.suite)
29
- assert_equal(2, @testsuite.count_test_cases)
30
-
31
- @testsuite.add(@dummy_test.suite)
32
- assert_equal(4, @testsuite.count_test_cases)
33
-
34
- dummytest_foo = @dummy_test.new('test_foo')
35
- @testsuite.add(dummytest_foo)
36
- assert_equal(5, @testsuite.count_test_cases)
37
- end
38
-
39
- def test_add
40
- @testsuite.add(@dummy_empty_test.suite)
41
- assert_equal(0, @testsuite.size)
42
- assert_equal(0, @testsuite.count_test_cases)
43
-
44
- @testsuite.add(@dummy_test.suite)
45
- assert_equal(2, @testsuite.size)
46
- assert_equal(2, @testsuite.count_test_cases)
47
- end
48
- end
49
- end