rubyunit 0.3.20 → 0.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd9ffda90dff8ebfa3160c4b4ceec4576e408342
4
- data.tar.gz: c70119c8318e8d5859e9d88970ed068501fd7b8f
3
+ metadata.gz: 75fe63431cbce5d2e16085376ff604bc88f3de26
4
+ data.tar.gz: 29bcadf52f69285f3bb015e9c19edadfb7f90059
5
5
  SHA512:
6
- metadata.gz: a29157a5f264788674d89c37bbc179decb028266ae4af93927370689abb7c522ce89b64a75b4f13d1f13a1f61c31854b70fc816699cab70d334dbf6540f8f728
7
- data.tar.gz: 42f7bfb1e1f8c6c9d3f9d665044ac467fc2a59aa9da70812fed6bec342d2efe76c7f5f8316a12772ebe2d73bb9bad7e9dd2f7053a5b163c94ce64c925a80b4f9
6
+ metadata.gz: cd237330bc5ea09c1a2cfaf9bbbfeda28037e2b557e03e49f11ed3d294417807f8cfe46a75faf3db944921a828dd44f321b01f86364c57677debc79158f920da
7
+ data.tar.gz: cfbb9dab0b5b457f4bab8ad15238207f3085f36e6d3e6fe6fc0331e8da2927fdcd91bb37a49cc3c5136d5948b0a04bcd1d7a1cb320b0a7e238252a2e7956fd23
@@ -13,7 +13,7 @@ module RubyUnit
13
13
 
14
14
  ##
15
15
  # Current RubyUnit version
16
- VERSION = '0.3.20'
16
+ VERSION = '0.3.21'
17
17
 
18
18
  ##
19
19
  # Set debug mode
@@ -0,0 +1,85 @@
1
+ require_relative 'Result'
2
+
3
+ module RubyUnit
4
+ ##
5
+ # The RubyUnit::Report module is the test results report
6
+ #
7
+ module Report
8
+ @@results = []
9
+ @@fail = []
10
+ @@skip = []
11
+ @@incomplete = []
12
+ @@errors = []
13
+
14
+ @@start = nil
15
+ @@finish = nil
16
+
17
+ def self.record result
18
+ @@results << result
19
+
20
+ case result.error
21
+ when RubyUnit::AssertionFailure
22
+ @@fail << result
23
+ when RubyUnit::SkippedTest
24
+ @@skip << result
25
+ when RubyUnit::IncompleteTest
26
+ @@incomplete << result
27
+ else
28
+ if result.error.class <= Exception
29
+ puts "error #{result.error.class}"
30
+ @@errors << result
31
+ end
32
+ end
33
+ end
34
+
35
+ def self.tests
36
+ @@results.count
37
+ end
38
+
39
+ def self.start
40
+ @@start = Time.new if @@start.nil?
41
+ @@start
42
+ end
43
+
44
+ def self.finish
45
+ @@finish = Time.new if @@finish.nil?
46
+ @@finish
47
+ end
48
+
49
+ def self.report type, results = [], trace = true
50
+ puts "\n#{results.count} #{type}:\n" if results.count > 0
51
+ results.each_with_index do |result, i|
52
+ puts "\n#{i + 1}) #{result.test_case}::#{result.test}(#{result.params})"
53
+ puts "#{result.error.class}: #{result.error.message}"
54
+ puts result.error.backtrace * "\n" if trace
55
+ end
56
+ end
57
+
58
+ def self.errors
59
+ report 'Errors in Tests', @@errors
60
+ end
61
+
62
+ def self.failures
63
+ report 'Failed Tests', @@fail
64
+ end
65
+
66
+ def self.skips
67
+ report 'Skipped Tests', @@skip, false
68
+ end
69
+
70
+ def self.incompletes
71
+ report 'Incomplete Tests', @@incomplete, false
72
+ end
73
+
74
+ def self.stats
75
+ elapsed = @@finish - @@start
76
+ inverse = Rational(elapsed.to_r.denominator,elapsed.to_r.numerator)
77
+ puts
78
+ puts "Tests Complete in #{elapsed} seconds!"
79
+ puts "%.3f tests/s, %.3f assertions/s" % [(tests * inverse).to_f, (TestCase.assertions * inverse).to_f]
80
+ puts "%d Assertions, %d Skipped Tests, %d Incomplete Tests" % [TestCase.assertions, @@skip.count, @@incomplete.count]
81
+ puts "%d Tests, %d Errors, %d Failures" % [tests, @@errors.count, @@fail.count]
82
+ puts
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,23 @@
1
+ module RubyUnit
2
+ ##
3
+ # The RubyUnit::Result class is a result of individual tests
4
+ #
5
+ class Result
6
+ attr_accessor :test_case, :test, :params, :error
7
+
8
+ @test_case
9
+ @test
10
+ @params
11
+ @error
12
+
13
+ def initialize test_case, test, params = [], error = nil
14
+ @test_case = test_case
15
+ @test = test
16
+ @params = params
17
+ @error = error
18
+
19
+ # Automatically add result to the test results...
20
+ Report.record self
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,6 @@
1
1
  require_relative 'TestCase'
2
2
  require_relative 'AssertionFailure'
3
+ require_relative 'Report'
3
4
 
4
5
  module RubyUnit
5
6
  #
@@ -27,12 +28,6 @@ module RubyUnit
27
28
  # The list of non RubyUnit::AssertionFailure exceptions that were caught by
28
29
  # the test runner during testing
29
30
  @@errors = []
30
- # The total number of tests that have been run
31
- @@tests = 0
32
- # The time the tests were started
33
- @@start = nil
34
- # The time the tests completed
35
- @@finish = nil
36
31
  # Whether or not the test suite still needs to be run. This is used by the
37
32
  # automatic runner to determine if it must be run before the program exits.
38
33
  @@autorun = true
@@ -48,15 +43,17 @@ module RubyUnit
48
43
  #
49
44
  def run
50
45
  @@autorun = false
51
- @@start = Time.new
52
46
  runner = new
47
+ puts "RubyUnit #{RubyUnit::VERSION}"
48
+ puts "Started Tests #{Report.start.strftime("%Y-%m-%d %H:%M:%S")}"
49
+
53
50
  TestCase.descendents.each do |test_case|
54
51
  @@test_cases << test_case
55
52
  object = test_case.new
56
53
  test_case.setup
57
54
 
58
- data_methods = test_case.instance_methods.grep /Data\Z/
59
- test_methods = test_case.instance_methods.grep /Test\Z/
55
+ data_methods = test_case.instance_methods.grep /Data$/
56
+ test_methods = test_case.instance_methods.grep /Test$/
60
57
 
61
58
  test_methods.each do |test|
62
59
  data_method = "#{test.slice(0..-5)}Data".to_sym
@@ -74,8 +71,8 @@ module RubyUnit
74
71
  end
75
72
  test_case.teardown
76
73
  end
77
- @@finish = Time.new
78
- report unless @@tests.zero?
74
+ Report.finish
75
+ report unless Report.tests.zero?
79
76
  @@failures.count + @@errors.count
80
77
  end
81
78
 
@@ -97,44 +94,11 @@ module RubyUnit
97
94
  # report # => nice and simple
98
95
  #
99
96
  def report
100
- # haven't figured out what I want to do for reporting yet but I need some results
101
- puts "RubyUnit #{RubyUnit::VERSION}"
102
- puts "Started Tests #{@@start.strftime("%Y-%m-%d %H:%M:%S")}"
103
-
104
- puts "#{@@errors.count} Errors:\n" if @@errors.count > 0
105
- @@errors.each_with_index do |error, i|
106
- puts "#{i + 1}) #{error[0]}::#{error[1]}(#{error[2]})"
107
- puts "#{error[3].class}: #{error[3].message}"
108
- puts error[3].backtrace.join("\n")
109
- end
110
-
111
- puts "#{@@skips.count} Skipped Tests:\n" if @@skips.count > 0
112
- @@skips.each_with_index do |skip, i|
113
- puts "#{i + 1}) #{skip[0]}::#{skip[1]}(#{skip[2]})"
114
- puts skip[3]
115
- end
116
-
117
- puts "#{@@incompletes.count} Skipped Tests:\n" if @@incompletes.count > 0
118
- @@incompletes.each_with_index do |incomplete, i|
119
- puts "#{i + 1}) #{incomplete[0]}::#{incomplete[1]}(#{incomplete[2]})"
120
- puts incomplete[3]
121
- end
122
-
123
- puts "#{@@failures.count} Failures:\n" if @@failures.count > 0
124
- @@failures.each_with_index do |failure, i|
125
- puts "#{i + 1}) #{failure[0]}::#{failure[1]}(#{failure[2]})"
126
- puts failure[3].info
127
- puts failure[3].backtrace.join("\n")
128
- end
129
-
130
- elapsed = @@finish - @@start
131
- inverse = Rational(elapsed.to_r.denominator,elapsed.to_r.numerator)
132
- puts
133
- puts "Tests Complete in #{elapsed} seconds!"
134
- puts "%.3f tests/s, %.3f assertions/s" % [(@@tests * inverse).to_f, (TestCase.assertions * inverse).to_f]
135
- puts "%d Assertions, %d Skipped Tests, %d Incomplete Tests" % [TestCase.assertions, @@skips.count, @@incompletes.count]
136
- puts "%d Tests, %d Errors, %d Failures" % [@@tests, @@errors.count, @@failures.count]
137
- puts
97
+ Report.errors
98
+ Report.skips
99
+ Report.incompletes
100
+ Report.failures
101
+ Report.stats
138
102
  end
139
103
  end
140
104
 
@@ -156,24 +120,18 @@ module RubyUnit
156
120
  #
157
121
  # run TestCaseClass, :myTest, [param1, param2]
158
122
  #
159
- def run test_case_class, test, params = []
123
+ def run klass, test, params = []
160
124
  raise TypeError, "Parameter list for #{object.class}::#{test} must be an array" unless params.is_a? Array
161
- test_case = test_case_class.new
125
+ test_case = klass.new
162
126
 
127
+ error = nil
163
128
  begin
164
- @@tests += 1
165
129
  test_case.setup
166
130
  test_case.send test, *params
167
131
  test_case.teardown
168
- rescue AssertionFailure => failure
169
- @@failures << [test_case.class.name, test, params, failure]
170
- rescue SkippedTest => skip
171
- @@skips << [test_case.class.name, test, params, skip]
172
- rescue IncompleteTest => incomplete
173
- @@incompletes << [test_case.class.name, test, params, incomplete]
174
132
  rescue Exception => error
175
- @@errors << [test_case.class.name, test, params, error]
176
133
  end
134
+ Result.new test_case.class, test, params, error
177
135
  end
178
136
  end
179
137
  end
@@ -4,14 +4,14 @@ require 'RubyUnit/Assertions'
4
4
  require_relative 'data/Comparisons'
5
5
 
6
6
  module AssertionsTests
7
- #
7
+ ##
8
8
  # Test Case for RubyUnit::Assertions Comparisons assertions
9
9
  #
10
10
  class TC_Comparisons < AssertionsTestCase
11
11
  include ComparisonsData
12
12
 
13
13
  ##
14
- # Test assertEqualTest
14
+ # Test assertEqual
15
15
  #
16
16
  # expected::
17
17
  # The expected value
@@ -24,7 +24,7 @@ module AssertionsTests
24
24
  end
25
25
 
26
26
  ##
27
- # Test assertEqualFailTest
27
+ # Test assertEqual failure
28
28
  #
29
29
  # expected::
30
30
  # The expected value
@@ -39,7 +39,7 @@ module AssertionsTests
39
39
  end
40
40
 
41
41
  ##
42
- # Test assertEqualWithMessageTest
42
+ # Test assertEqual with message
43
43
  #
44
44
  # expected::
45
45
  # The expected value
@@ -55,7 +55,7 @@ module AssertionsTests
55
55
  end
56
56
 
57
57
  ##
58
- # Test assertEqualWithMessageFailTest
58
+ # Test assertEqual with message failure
59
59
  #
60
60
  # expected::
61
61
  # The expected value
@@ -73,7 +73,7 @@ module AssertionsTests
73
73
  end
74
74
 
75
75
  ##
76
- # Test assertNotEqualTest
76
+ # Test assertNotEqual
77
77
  #
78
78
  # expected::
79
79
  # The expected value
@@ -86,7 +86,7 @@ module AssertionsTests
86
86
  end
87
87
 
88
88
  ##
89
- # Test assertNotEqualFailTest
89
+ # Test assertNotEqual failure
90
90
  #
91
91
  # expected::
92
92
  # The expected value
@@ -101,7 +101,7 @@ module AssertionsTests
101
101
  end
102
102
 
103
103
  ##
104
- # Test assertNotEqualWithMessageTest
104
+ # Test assertNotEqual with message
105
105
  #
106
106
  # expected::
107
107
  # The expected value
@@ -117,7 +117,7 @@ module AssertionsTests
117
117
  end
118
118
 
119
119
  ##
120
- # Test assertNotEqualWithMessageFailTest
120
+ # Test assertNotEqual with message failure
121
121
  #
122
122
  # expected::
123
123
  # The expected value
@@ -135,7 +135,7 @@ module AssertionsTests
135
135
  end
136
136
 
137
137
  ##
138
- # Test assertGreaterThanTest
138
+ # Test assertGreaterThan
139
139
  #
140
140
  # greater::
141
141
  # The greater value
@@ -148,7 +148,7 @@ module AssertionsTests
148
148
  end
149
149
 
150
150
  ##
151
- # Test assertGreaterThanFailTest
151
+ # Test assertGreaterThan failure
152
152
  #
153
153
  # greater::
154
154
  # The greater value
@@ -163,7 +163,7 @@ module AssertionsTests
163
163
  end
164
164
 
165
165
  ##
166
- # Test assertGreaterThanWithMessageTest
166
+ # Test assertGreaterThan with message
167
167
  #
168
168
  # greater::
169
169
  # The greater value
@@ -179,7 +179,7 @@ module AssertionsTests
179
179
  end
180
180
 
181
181
  ##
182
- # Test assertGreaterThanWithMessageFailTest
182
+ # Test assertGreaterThan with message failure
183
183
  #
184
184
  # greater::
185
185
  # The greater value
@@ -197,7 +197,7 @@ module AssertionsTests
197
197
  end
198
198
 
199
199
  ##
200
- # Test assertGreaterThanOrEqualTest
200
+ # Test assertGreaterThanOrEqual
201
201
  #
202
202
  # greater::
203
203
  # The greater value
@@ -210,7 +210,7 @@ module AssertionsTests
210
210
  end
211
211
 
212
212
  ##
213
- # Test assertGreaterThanOrEqualFailTest
213
+ # Test assertGreaterThanOrEqual failure
214
214
  #
215
215
  # greater::
216
216
  # The greater value
@@ -225,7 +225,7 @@ module AssertionsTests
225
225
  end
226
226
 
227
227
  ##
228
- # Test assertGreaterThanOrEqualWithMessageTest
228
+ # Test assertGreaterThanOrEqual with message
229
229
  #
230
230
  # greater::
231
231
  # The greater value
@@ -241,7 +241,7 @@ module AssertionsTests
241
241
  end
242
242
 
243
243
  ##
244
- # Test assertGreaterThanOrEqualWithMessageFailTest
244
+ # Test assertGreaterThanOrEqual with message failure
245
245
  #
246
246
  # greater::
247
247
  # The greater value
@@ -259,7 +259,7 @@ module AssertionsTests
259
259
  end
260
260
 
261
261
  ##
262
- # Test assertLessThanTest
262
+ # Test assertLessThan
263
263
  #
264
264
  # lesser::
265
265
  # The lesser value
@@ -272,7 +272,7 @@ module AssertionsTests
272
272
  end
273
273
 
274
274
  ##
275
- # Test assertLessThanFailTest
275
+ # Test assertLessThan failure
276
276
  #
277
277
  # lesser::
278
278
  # The lesser value
@@ -287,7 +287,7 @@ module AssertionsTests
287
287
  end
288
288
 
289
289
  ##
290
- # Test assertLessThanWithMessageTest
290
+ # Test assertLessThan with message
291
291
  #
292
292
  # lesser::
293
293
  # The lesser value
@@ -303,7 +303,7 @@ module AssertionsTests
303
303
  end
304
304
 
305
305
  ##
306
- # Test assertLessThanWithMessageFailTest
306
+ # Test assertLessThan with message failure
307
307
  #
308
308
  # lesser::
309
309
  # The lesser value
@@ -321,7 +321,7 @@ module AssertionsTests
321
321
  end
322
322
 
323
323
  ##
324
- # Test assertLessThanOrEqualTest
324
+ # Test assertLessThanOrEqual
325
325
  #
326
326
  # lesser::
327
327
  # The lesser value
@@ -334,7 +334,7 @@ module AssertionsTests
334
334
  end
335
335
 
336
336
  ##
337
- # Test assertLessThanOrEqualFailTest
337
+ # Test assertLessThanOrEqual failure
338
338
  #
339
339
  # lesser::
340
340
  # The lesser value
@@ -349,7 +349,7 @@ module AssertionsTests
349
349
  end
350
350
 
351
351
  ##
352
- # Test assertLessThanOrEqualWithMessageTest
352
+ # Test assertLessThanOrEqual with message
353
353
  #
354
354
  # lesser::
355
355
  # The lesser value
@@ -365,7 +365,7 @@ module AssertionsTests
365
365
  end
366
366
 
367
367
  ##
368
- # Test assertLessThanOrEqualWithMessageFailTest
368
+ # Test assertLessThanOrEqual with message failure
369
369
  #
370
370
  # lesser::
371
371
  # The lesser value
@@ -383,7 +383,7 @@ module AssertionsTests
383
383
  end
384
384
 
385
385
  ##
386
- # Test assertMatchTest
386
+ # Test assertMatch
387
387
  #
388
388
  # pattern::
389
389
  # The pattern to check against
@@ -396,7 +396,7 @@ module AssertionsTests
396
396
  end
397
397
 
398
398
  ##
399
- # Test assertMatchFailTest
399
+ # Test assertMatch failure
400
400
  #
401
401
  # pattern::
402
402
  # The pattern to check against
@@ -411,7 +411,7 @@ module AssertionsTests
411
411
  end
412
412
 
413
413
  ##
414
- # Test assertMatchWithMessageTest
414
+ # Test assertMatch with message
415
415
  #
416
416
  # pattern::
417
417
  # The pattern to check against
@@ -427,7 +427,7 @@ module AssertionsTests
427
427
  end
428
428
 
429
429
  ##
430
- # Test assertMatchWithMessageFailTest
430
+ # Test assertMatch with message failure
431
431
  #
432
432
  # pattern::
433
433
  # The pattern to check against
@@ -445,7 +445,7 @@ module AssertionsTests
445
445
  end
446
446
 
447
447
  ##
448
- # Test assertNotMatchTest
448
+ # Test assertNotMatch
449
449
  #
450
450
  # pattern::
451
451
  # The pattern to check against
@@ -458,7 +458,7 @@ module AssertionsTests
458
458
  end
459
459
 
460
460
  ##
461
- # Test assertNotMatchFailTest
461
+ # Test assertNotMatch failure
462
462
  #
463
463
  # pattern::
464
464
  # The pattern to check against
@@ -473,7 +473,7 @@ module AssertionsTests
473
473
  end
474
474
 
475
475
  ##
476
- # Test assertNotMatchWithMessageTest
476
+ # Test assertNotMatch with message
477
477
  #
478
478
  # pattern::
479
479
  # The pattern to check against
@@ -489,7 +489,7 @@ module AssertionsTests
489
489
  end
490
490
 
491
491
  ##
492
- # Test assertNotMatchWithMessageFailTest
492
+ # Test assertNotMatch with message failure
493
493
  #
494
494
  # pattern::
495
495
  # The pattern to check against
@@ -507,7 +507,7 @@ module AssertionsTests
507
507
  end
508
508
 
509
509
  ##
510
- # Test assertSameTest
510
+ # Test assertSame
511
511
  #
512
512
  # object::
513
513
  # The object to check
@@ -517,7 +517,7 @@ module AssertionsTests
517
517
  end
518
518
 
519
519
  ##
520
- # Test assertSameFailTest
520
+ # Test assertSame failure
521
521
  #
522
522
  # expected::
523
523
  # The expected object to check against
@@ -532,7 +532,7 @@ module AssertionsTests
532
532
  end
533
533
 
534
534
  ##
535
- # Test assertSameWithMessageTest
535
+ # Test assertSame with message
536
536
  #
537
537
  # object::
538
538
  # The object to check
@@ -545,7 +545,7 @@ module AssertionsTests
545
545
  end
546
546
 
547
547
  ##
548
- # Test assertSameWithMessageFailTest
548
+ # Test assertSame with message failure
549
549
  #
550
550
  # expected::
551
551
  # The expected object to check against
@@ -563,7 +563,7 @@ module AssertionsTests
563
563
  end
564
564
 
565
565
  ##
566
- # Test assertNotSameTest
566
+ # Test assertNotSame
567
567
  #
568
568
  # expected::
569
569
  # The expected object to check against
@@ -576,7 +576,7 @@ module AssertionsTests
576
576
  end
577
577
 
578
578
  ##
579
- # Test assertNotSameFailTest
579
+ # Test assertNotSame failure
580
580
  #
581
581
  # object::
582
582
  # The object to check
@@ -588,7 +588,7 @@ module AssertionsTests
588
588
  end
589
589
 
590
590
  ##
591
- # Test assertNotSameWithMessageTest
591
+ # Test assertNotSame with message
592
592
  #
593
593
  # expected::
594
594
  # The expected object to check against
@@ -604,7 +604,7 @@ module AssertionsTests
604
604
  end
605
605
 
606
606
  ##
607
- # Test assertNotSameWithMessageFailTest
607
+ # Test assertNotSame with message failure
608
608
  #
609
609
  # object::
610
610
  # The object to check
@@ -13,12 +13,21 @@ module AssertionsTests
13
13
  class TC_Exceptions < AssertionsTestCase
14
14
  include ExceptionsData
15
15
 
16
+ ##
17
+ # Test assertNothingRaised
18
+ #
19
+ # block_data::
20
+ # block to be asserted
21
+ #
16
22
  def assertNothingRaisedTest block_data
17
23
  assertNothingRaised do
18
24
  block_data
19
25
  end
20
26
  end
21
27
 
28
+ ##
29
+ # Test assertNothingRaised failure
30
+ #
22
31
  def assertNothingRaisedFailTest
23
32
  rescue_assertion /#{ASSERT_NOTHING_RAISED_ERROR}/ do
24
33
  assertNothingRaised do
@@ -27,12 +36,27 @@ module AssertionsTests
27
36
  end
28
37
  end
29
38
 
39
+ ##
40
+ # Test assertNothingRaised with message
41
+ #
42
+ # block_data::
43
+ # block to be asserted
44
+ #
45
+ # message::
46
+ # The assertion message
47
+ #
30
48
  def assertNothingRaisedWithMessageTest block_data, message
31
49
  assertNothingRaised message do
32
50
  block_data
33
51
  end
34
52
  end
35
53
 
54
+ ##
55
+ # Test assertNothingRaised with message failure
56
+ #
57
+ # message::
58
+ # The assertion message
59
+ #
36
60
  def assertNothingRaisedWithMessageFailTest message
37
61
  rescue_assertion /#{ASSERT_NOTHING_RAISED_ERROR}/, message do
38
62
  assertNothingRaised message do
@@ -41,20 +65,50 @@ module AssertionsTests
41
65
  end
42
66
  end
43
67
 
68
+ ##
69
+ # Test assertRaiseMessage
70
+ #
71
+ # pattern::
72
+ # The pattern to match the exception
73
+ #
74
+ # exception::
75
+ # The exception to raise
76
+ #
77
+ # error::
78
+ # The exception message
79
+ #
44
80
  def assertRaiseMessageTest pattern, exception, error
45
81
  assertRaiseMessage pattern do
46
82
  raise exception, error
47
83
  end
48
84
  end
49
85
 
50
- def assertRaiseMessageFailTest pattern, exception
86
+ ##
87
+ # Test assertRaiseMessage failure
88
+ #
89
+ # pattern::
90
+ # The pattern to match the exception
91
+ #
92
+ # exception::
93
+ # The exception to raise
94
+ #
95
+ # error::
96
+ # The exception message
97
+ #
98
+ def assertRaiseMessageFailTest pattern, exception, error
51
99
  rescue_assertion /#{ASSERT_RAISE_MESSAGE_ERROR}/ do
52
100
  assertRaiseMessage pattern do
53
- raise exception
101
+ raise exception, error
54
102
  end
55
103
  end
56
104
  end
57
105
 
106
+ ##
107
+ # Test assertRaiseMessage with invalid input
108
+ #
109
+ # pattern::
110
+ # The pattern to match the exception
111
+ #
58
112
  def assertRaiseMessageInvalidTest pattern
59
113
  assertRaiseKindOf TypeError do
60
114
  assertRaiseMessage pattern do
@@ -63,20 +117,59 @@ module AssertionsTests
63
117
  end
64
118
  end
65
119
 
120
+ ##
121
+ # Test assertRaiseMessage with message
122
+ #
123
+ # pattern::
124
+ # The pattern to match the exception
125
+ #
126
+ # exception::
127
+ # The exception to raise
128
+ #
129
+ # error::
130
+ # The exception message
131
+ #
132
+ # message::
133
+ # The assertion message
134
+ #
66
135
  def assertRaiseMessageWithMessageTest pattern, exception, error, message
67
136
  assertRaiseMessage pattern, message do
68
137
  raise exception, error
69
138
  end
70
139
  end
71
140
 
72
- def assertRaiseMessageWithMessageFailTest pattern, exception, message
141
+ ##
142
+ # Test assertRaiseMessage with message failure
143
+ #
144
+ # pattern::
145
+ # The pattern to match the exception
146
+ #
147
+ # exception::
148
+ # The exception to raise
149
+ #
150
+ # error::
151
+ # The exception message
152
+ #
153
+ # message::
154
+ # The assertion message
155
+ #
156
+ def assertRaiseMessageWithMessageFailTest pattern, exception, error, message
73
157
  rescue_assertion /#{ASSERT_RAISE_MESSAGE_ERROR}/, message do
74
158
  assertRaiseMessage pattern, message do
75
- raise exception
159
+ raise exception, error
76
160
  end
77
161
  end
78
162
  end
79
163
 
164
+ ##
165
+ # Test assertRaiseMessage with invalid input with message
166
+ #
167
+ # pattern::
168
+ # The pattern to match the exception
169
+ #
170
+ # message::
171
+ # The assertion message
172
+ #
80
173
  def assertRaiseMessageWithMessageInvalidTest pattern, message
81
174
  assertRaiseKindOf TypeError do
82
175
  assertRaiseMessage pattern, message do
@@ -85,12 +178,24 @@ module AssertionsTests
85
178
  end
86
179
  end
87
180
 
181
+ ##
182
+ # Test assertRaiseKindOf
183
+ #
184
+ # exception::
185
+ # The exception to raise
186
+ #
88
187
  def assertRaiseKindOfTest exception
89
188
  assertRaiseKindOf exception do
90
189
  raise exception
91
190
  end
92
191
  end
93
192
 
193
+ ##
194
+ # Test assertRaiseKindOf failure
195
+ #
196
+ # exception::
197
+ # The exception to raise
198
+ #
94
199
  def assertRaiseKindOfFailTest exception
95
200
  rescue_assertion /#{ASSERT_RAISE_KIND_OF_ERROR}/ do
96
201
  assertRaiseKindOf AssertionsTestsError do
@@ -99,6 +204,12 @@ module AssertionsTests
99
204
  end
100
205
  end
101
206
 
207
+ ##
208
+ # Test assertRaiseKindOf with invalid input
209
+ #
210
+ # exception::
211
+ # The exception to raise
212
+ #
102
213
  def assertRaiseKindOfInvalidTest exception
103
214
  assertRaiseKindOf TypeError do
104
215
  assertRaiseKindOf exception do
@@ -107,12 +218,30 @@ module AssertionsTests
107
218
  end
108
219
  end
109
220
 
221
+ ##
222
+ # Test assertRaiseKindOf with message
223
+ #
224
+ # exception::
225
+ # The exception to raise
226
+ #
227
+ # message::
228
+ # The assertion message
229
+ #
110
230
  def assertRaiseKindOfWithMessageTest exception, message
111
231
  assertRaiseKindOf exception, message do
112
232
  raise exception
113
233
  end
114
234
  end
115
235
 
236
+ ##
237
+ # Test assertRaiseKindOf with message failure
238
+ #
239
+ # exception::
240
+ # The exception to raise
241
+ #
242
+ # message::
243
+ # The assertion message
244
+ #
116
245
  def assertRaiseKindOfWithMessageFailTest exception, message
117
246
  rescue_assertion /#{ASSERT_RAISE_KIND_OF_ERROR}/, message do
118
247
  assertRaiseKindOf AssertionsTestsError, message do
@@ -121,6 +250,15 @@ module AssertionsTests
121
250
  end
122
251
  end
123
252
 
253
+ ##
254
+ # Test assertRaiseKindOf with invalid input with message
255
+ #
256
+ # exception::
257
+ # The exception to raise
258
+ #
259
+ # message::
260
+ # The assertion message
261
+ #
124
262
  def assertRaiseKindOfWithMessageInvalidTest exception, message
125
263
  assertRaiseKindOf TypeError do
126
264
  assertRaiseKindOf exception, message do
@@ -129,10 +267,203 @@ module AssertionsTests
129
267
  end
130
268
  end
131
269
 
270
+ ##
271
+ # Test assertRaiseExpected
272
+ #
273
+ # pattern::
274
+ # The pattern to match the exception
275
+ #
276
+ # exception::
277
+ # The exception to raise
278
+ #
279
+ # error::
280
+ # The exception message
281
+ #
132
282
  def assertRaiseExpectedTest pattern, exception, error
133
- assertRaisedExpected exception, pattern do
283
+ assertRaiseExpected exception, pattern do
284
+ raise exception, error
285
+ end
286
+ end
287
+
288
+ ##
289
+ # Test assertRaiseExpected failure
290
+ #
291
+ # pattern::
292
+ # The pattern to match the exception
293
+ #
294
+ # expected::
295
+ # The exception that is expected to be raised
296
+ #
297
+ # exception::
298
+ # The exception to raise
299
+ #
300
+ # error::
301
+ # The exception message
302
+ #
303
+ def assertRaiseExpectedFailTest pattern, expected, exception, error
304
+ rescue_assertion /#{ASSERT_RAISE_EXPECTED_ERROR}/ do
305
+ assertRaiseExpected expected, pattern do
306
+ raise exception, error
307
+ end
308
+ end
309
+ end
310
+
311
+ ##
312
+ # Test assertRaiseExpected with invalid exception
313
+ #
314
+ # pattern::
315
+ # The pattern to match the exception
316
+ #
317
+ # expected::
318
+ # The exception that is expected to be raised
319
+ #
320
+ def assertRaiseExpectedInvalidExceptionTest pattern, expected
321
+ assertRaiseKindOf TypeError do
322
+ assertRaiseExpected expected, pattern do
323
+ raise StandardError, pattern
324
+ end
325
+ end
326
+ end
327
+
328
+ ##
329
+ # Test assertRaiseExpected with invalid error
330
+ #
331
+ # pattern::
332
+ # The pattern to match the exception
333
+ #
334
+ # expected::
335
+ # The exception that is expected to be raised
336
+ #
337
+ def assertRaiseExpectedInvalidErrorTest pattern, expected
338
+ assertRaiseKindOf TypeError do
339
+ assertRaiseExpected expected, pattern do
340
+ raise StandardError, pattern
341
+ end
342
+ end
343
+ end
344
+
345
+ ##
346
+ # Test assertRaiseExpected with invalid exception and error
347
+ #
348
+ # pattern::
349
+ # The pattern to match the exception
350
+ #
351
+ # expected::
352
+ # The exception that is expected to be raised
353
+ #
354
+ def assertRaiseExpectedInvalidBothTest pattern, expected
355
+ assertRaiseKindOf TypeError do
356
+ assertRaiseExpected expected, pattern do
357
+ raise StandardError, pattern
358
+ end
359
+ end
360
+ end
361
+
362
+ ##
363
+ # Test assertRaiseExpected with message
364
+ #
365
+ # pattern::
366
+ # The pattern to match the exception
367
+ #
368
+ # exception::
369
+ # The exception to raise
370
+ #
371
+ # error::
372
+ # The exception message
373
+ #
374
+ # message::
375
+ # The assertion message
376
+ #
377
+ def assertRaiseExpectedWithMessageTest pattern, exception, error, message
378
+ assertRaiseExpected exception, pattern, message do
134
379
  raise exception, error
135
380
  end
136
381
  end
382
+
383
+ ##
384
+ # Test assertRaiseExpected with message failure
385
+ #
386
+ # pattern::
387
+ # The pattern to match the exception
388
+ #
389
+ # expected::
390
+ # The exception that is expected to be raised
391
+ #
392
+ # exception::
393
+ # The exception to raise
394
+ #
395
+ # error::
396
+ # The exception message
397
+ #
398
+ # message::
399
+ # The assertion message
400
+ #
401
+ def assertRaiseExpectedWithMessageFailTest pattern, expected, exception, error, message
402
+ rescue_assertion /#{ASSERT_RAISE_EXPECTED_ERROR}/ do
403
+ assertRaiseExpected expected, pattern, message do
404
+ raise exception, error
405
+ end
406
+ end
407
+ end
408
+
409
+ ##
410
+ # Test assertRaiseExpected with invalid exception with message
411
+ #
412
+ # pattern::
413
+ # The pattern to match the exception
414
+ #
415
+ # expected::
416
+ # The exception that is expected to be raised
417
+ #
418
+ # message::
419
+ # The assertion message
420
+ #
421
+ def assertRaiseExpectedInvalidExceptionWithMessageTest pattern, expected, message
422
+ assertRaiseKindOf TypeError do
423
+ assertRaiseExpected expected, pattern, message do
424
+ raise StandardError, pattern
425
+ end
426
+ end
427
+ end
428
+
429
+ ##
430
+ # Test assertRaiseExpected with invalid error with message
431
+ #
432
+ # pattern::
433
+ # The pattern to match the exception
434
+ #
435
+ # expected::
436
+ # The exception that is expected to be raised
437
+ #
438
+ # message::
439
+ # The assertion message
440
+ #
441
+ def assertRaiseExpectedInvalidErrorWithMessageTest pattern, expected, message
442
+ assertRaiseKindOf TypeError do
443
+ assertRaiseExpected expected, pattern, message do
444
+ raise StandardError, pattern
445
+ end
446
+ end
447
+ end
448
+
449
+ ##
450
+ # Test assertRaiseExpected with invalid exception and error with message
451
+ #
452
+ # pattern::
453
+ # The pattern to match the exception
454
+ #
455
+ # expected::
456
+ # The exception that is expected to be raised
457
+ #
458
+ # message::
459
+ # The assertion message
460
+ #
461
+ def assertRaiseExpectedInvalidBothWithMessageTest pattern, expected, message
462
+ assertRaiseKindOf TypeError do
463
+ assertRaiseExpected expected, pattern, message do
464
+ raise StandardError, pattern
465
+ end
466
+ end
467
+ end
137
468
  end
138
469
  end
@@ -28,6 +28,15 @@ module AssertionsTests
28
28
  end
29
29
  alias_method :assertRaiseExpectedData, :assertRaiseMessageData
30
30
 
31
+ def assertRaiseMessageFailData
32
+ [
33
+ [/Message$/, Exception, 'Message raised'],
34
+ [/No Match/, StandardError, 'Message raised'],
35
+ [ 'Message', ArgumentError, 'Message raised'],
36
+ ['No Match', TypeError, 'Message raised'],
37
+ ]
38
+ end
39
+
31
40
  def assertRaiseMessageInvalidData
32
41
  exceptionObjects +
33
42
  nilObjects +
@@ -44,18 +53,10 @@ module AssertionsTests
44
53
  hashObjects
45
54
  end
46
55
 
47
- def assertRaiseMessageFailData
48
- [
49
- [ /Message$/, Exception],
50
- [ /No Match/, StandardError],
51
- [ 'Message', ArgumentError],
52
- [ 'No Match', TypeError],
53
- ]
54
- end
55
-
56
56
  def assertRaiseMessageWithMessageData
57
57
  add_parameter assertRaiseMessageData
58
58
  end
59
+ alias_method :assertRaiseExpectedWithMessageData, :assertRaiseMessageWithMessageData
59
60
 
60
61
  def assertRaiseMessageWithMessageFailData
61
62
  add_parameter assertRaiseMessageFailData
@@ -99,10 +100,48 @@ module AssertionsTests
99
100
  add_parameter assertRaiseKindOfInvalidData
100
101
  end
101
102
 
102
- def assertRaiseExpectedData
103
+ def assertRaiseExpectedFailData
103
104
  [
104
-
105
+ [ /Message$/, Exception, Exception, 'Message raised'],
106
+ [ /No Match/, StandardError, StandardError, 'Message raised'],
107
+ [ 'Message', ArgumentError, ArgumentError, 'Message raised'],
108
+ [ 'No Match', TypeError, TypeError, 'Message raised'],
109
+ ['Message raised', StandardError, Exception, 'Message raised'],
110
+ ['Message raised', ArgumentError, StandardError, 'Message raised'],
111
+ ['Message raised', TypeError, ArgumentError, 'Message raised'],
112
+ [ /Message$/, StandardError, Exception, 'Message raised'],
113
+ [ /No Match/, ArgumentError, StandardError, 'Message raised'],
114
+ [ 'Message', TypeError, ArgumentError, 'Message raised'],
115
+ [ 'No Match', Exception, TypeError, 'Message raised'],
105
116
  ]
106
117
  end
118
+
119
+ def assertRaiseExpectedInvalidExceptionData
120
+ add_parameter MESSAGE, assertRaiseKindOfInvalidData
121
+ end
122
+
123
+ def assertRaiseExpectedInvalidErrorData
124
+ add_parameter assertRaiseMessageInvalidData, [[StandardError]]
125
+ end
126
+
127
+ def assertRaiseExpectedInvalidBothData
128
+ add_parameter assertRaiseMessageInvalidData, assertRaiseKindOfInvalidData
129
+ end
130
+
131
+ def assertRaiseExpectedWithMessageFailData
132
+ add_parameter assertRaiseExpectedFailData
133
+ end
134
+
135
+ def assertRaiseExpectedInvalidExceptionWithMessageData
136
+ add_parameter assertRaiseExpectedInvalidExceptionData
137
+ end
138
+
139
+ def assertRaiseExpectedInvalidErrorWithMessageData
140
+ add_parameter assertRaiseExpectedInvalidErrorData
141
+ end
142
+
143
+ def assertRaiseExpectedInvalidBothWithMessageData
144
+ add_parameter assertRaiseExpectedInvalidBothData
145
+ end
107
146
  end
108
147
  end
@@ -151,7 +151,6 @@ module AssertionsTests
151
151
  [ ''],
152
152
  [ 'string one'],
153
153
  [ "STRING 2"],
154
- [ "String #{42}"],
155
154
  [ 'Two Word string'],
156
155
  ["Three\nLINE\nString"],
157
156
  ]
@@ -169,11 +168,10 @@ module AssertionsTests
169
168
 
170
169
  def regexpObjects
171
170
  [
172
- [ //],
173
- [ /Regexp 1/],
174
- [ /\AStart Regexp/],
175
- [ /END regexp$/],
176
- [/^#{'interpolated'} REGEXP$/],
171
+ [ //],
172
+ [ /Regexp 1/],
173
+ [/\AStart Regexp/],
174
+ [ /END regexp$/],
177
175
  ]
178
176
  end
179
177
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.20
4
+ version: 0.3.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Clower
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -54,6 +54,8 @@ files:
54
54
  - lib/RubyUnit/Assertions/Methods.rb
55
55
  - lib/RubyUnit/Assertions/Root.rb
56
56
  - lib/RubyUnit/IncompleteTest.rb
57
+ - lib/RubyUnit/Report.rb
58
+ - lib/RubyUnit/Result.rb
57
59
  - lib/RubyUnit/Runner.rb
58
60
  - lib/RubyUnit/SkippedTest.rb
59
61
  - lib/RubyUnit/TestCase.rb