test-unit 3.2.0 → 3.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/COPYING +4 -1
  3. data/README.md +11 -11
  4. data/Rakefile +10 -1
  5. data/doc/text/getting-started.md +246 -0
  6. data/doc/text/news.md +372 -1
  7. data/lib/test/unit.rb +171 -157
  8. data/lib/test/unit/assertions.rb +187 -149
  9. data/lib/test/unit/attribute.rb +71 -2
  10. data/lib/test/unit/autorunner.rb +65 -32
  11. data/lib/test/unit/code-snippet-fetcher.rb +7 -7
  12. data/lib/test/unit/collector/load.rb +8 -13
  13. data/lib/test/unit/data-sets.rb +116 -0
  14. data/lib/test/unit/data.rb +121 -12
  15. data/lib/test/unit/diff.rb +11 -11
  16. data/lib/test/unit/fixture.rb +3 -0
  17. data/lib/test/unit/notification.rb +9 -7
  18. data/lib/test/unit/omission.rb +34 -31
  19. data/lib/test/unit/pending.rb +12 -11
  20. data/lib/test/unit/priority.rb +7 -3
  21. data/lib/test/unit/runner/console.rb +25 -0
  22. data/lib/test/unit/test-suite-creator.rb +22 -8
  23. data/lib/test/unit/testcase.rb +270 -182
  24. data/lib/test/unit/ui/console/testrunner.rb +90 -35
  25. data/lib/test/unit/ui/emacs/testrunner.rb +5 -5
  26. data/lib/test/unit/util/observable.rb +2 -2
  27. data/lib/test/unit/util/output.rb +5 -4
  28. data/lib/test/unit/util/procwrapper.rb +4 -4
  29. data/lib/test/unit/version.rb +1 -1
  30. data/test/collector/test-descendant.rb +4 -0
  31. data/test/collector/test-load.rb +35 -2
  32. data/test/collector/test_dir.rb +5 -4
  33. data/test/collector/test_objectspace.rb +7 -5
  34. data/test/test-assertions.rb +128 -101
  35. data/test/test-code-snippet.rb +42 -0
  36. data/test/test-data.rb +195 -79
  37. data/test/test-priority.rb +19 -8
  38. data/test/test-test-case.rb +111 -3
  39. data/test/test-test-suite.rb +1 -0
  40. data/test/testunit-test-util.rb +2 -0
  41. metadata +38 -37
@@ -3,10 +3,10 @@ require 'test/unit/autorunner'
3
3
 
4
4
  module Test # :nodoc:
5
5
  #
6
- # = Test::Unit - Ruby Unit Testing Framework
7
- #
8
- # == Introduction
9
- #
6
+ # # Test::Unit - Ruby Unit Testing Framework
7
+ #
8
+ # ## Introduction
9
+ #
10
10
  # Unit testing is making waves all over the place, largely due to the
11
11
  # fact that it is a core practice of XP. While XP is great, unit testing
12
12
  # has been around for a long time and has always been a good idea. One
@@ -18,19 +18,19 @@ module Test # :nodoc:
18
18
  # as possible, you slowly build up a wall of things that cannot break
19
19
  # without you immediately knowing about it. This is when unit testing
20
20
  # hits its peak usefulness.
21
- #
21
+ #
22
22
  # Enter Test::Unit, a framework for unit testing in Ruby, helping you to
23
23
  # design, debug and evaluate your code by making it easy to write and
24
24
  # have tests for it.
25
- #
26
- #
27
- # == Notes
28
- #
25
+ #
26
+ #
27
+ # ## Notes
28
+ #
29
29
  # Test::Unit has grown out of and superceded Lapidary.
30
- #
31
- #
32
- # == Feedback
33
- #
30
+ #
31
+ #
32
+ # ## Feedback
33
+ #
34
34
  # I like (and do my best to practice) XP, so I value early releases,
35
35
  # user feedback, and clean, simple, expressive code. There is always
36
36
  # room for improvement in everything I do, and Test::Unit is no
@@ -41,79 +41,84 @@ module Test # :nodoc:
41
41
  # hear about any successes you have with Test::Unit, and any
42
42
  # documentation you might add will be greatly appreciated. My contact
43
43
  # info is below.
44
- #
45
- #
46
- # == Contact Information
47
- #
48
- # A lot of discussion happens about Ruby in general on the ruby-talk
49
- # mailing list (http://www.ruby-lang.org/en/ml.html), and you can ask
50
- # any questions you might have there. I monitor the list, as do many
51
- # other helpful Rubyists, and you're sure to get a quick answer. Of
52
- # course, you're also welcome to email me (Nathaniel Talbott) directly
53
- # at mailto:testunit@talbott.ws, and I'll do my best to help you out.
54
- #
55
- #
56
- # == Credits
57
- #
44
+ #
45
+ #
46
+ # ## Contact Information
47
+ #
48
+ # * [GitHub issues on
49
+ # test-unit/test-unit](https://github.com/test-unit/test-unit/issues):
50
+ # If you have any issues, please report them to here.
51
+ #
52
+ # * [GitHub pull requests on
53
+ # test-unit/test-unit](https://github.com/test-unit/test-unit/pulls):
54
+ # If you have any patches, please report them to here.
55
+ #
56
+ # * [ruby-talk mailing
57
+ # list](https://www.ruby-lang.org/en/community/mailing-lists/):
58
+ # If you have any questions, you can ask them here.
59
+ #
60
+ #
61
+ # ## Credits
62
+ #
58
63
  # I'd like to thank...
59
- #
64
+ #
60
65
  # Matz, for a great language!
61
- #
66
+ #
62
67
  # Masaki Suketa, for his work on RubyUnit, which filled a vital need in
63
68
  # the Ruby world for a very long time. I'm also grateful for his help in
64
69
  # polishing Test::Unit and getting the RubyUnit compatibility layer
65
70
  # right. His graciousness in allowing Test::Unit to supercede RubyUnit
66
71
  # continues to be a challenge to me to be more willing to defer my own
67
72
  # rights.
68
- #
73
+ #
69
74
  # Ken McKinlay, for his interest and work on unit testing, and for his
70
75
  # willingness to dialog about it. He was also a great help in pointing
71
76
  # out some of the holes in the RubyUnit compatibility layer.
72
- #
77
+ #
73
78
  # Dave Thomas, for the original idea that led to the extremely simple
74
79
  # "require 'test/unit'", plus his code to improve it even more by
75
80
  # allowing the selection of tests from the command-line. Also, without
76
81
  # RDoc, the documentation for Test::Unit would stink a lot more than it
77
82
  # does now.
78
- #
83
+ #
79
84
  # Everyone who's helped out with bug reports, feature ideas,
80
85
  # encouragement to continue, etc. It's a real privilege to be a part of
81
86
  # the Ruby community.
82
- #
87
+ #
83
88
  # The guys at RoleModel Software, for putting up with me repeating, "But
84
89
  # this would be so much easier in Ruby!" whenever we're coding in Java.
85
- #
90
+ #
86
91
  # My Creator, for giving me life, and giving it more abundantly.
87
- #
88
- #
89
- # == License
90
- #
92
+ #
93
+ #
94
+ # ## License
95
+ #
91
96
  # Test::Unit is copyright (c) 2000-2003 Nathaniel Talbott. It is free
92
97
  # software, and is distributed under the Ruby license. See the COPYING
93
98
  # file.
94
- #
99
+ #
95
100
  # Exception: lib/test/unit/diff.rb is copyright (c)
96
101
  # 2008-2010 Kouhei Sutou and 2001-2008 Python Software
97
102
  # Foundation. It is free software, and is distributed
98
103
  # under the Ruby license and/or the PSF license. See the
99
104
  # COPYING file and PSFL file.
100
- #
101
- # == Warranty
102
- #
105
+ #
106
+ # ## Warranty
107
+ #
103
108
  # This software is provided "as is" and without any express or
104
109
  # implied warranties, including, without limitation, the implied
105
110
  # warranties of merchantibility and fitness for a particular
106
111
  # purpose.
107
- #
108
- #
109
- # == Author
110
- #
112
+ #
113
+ #
114
+ # ## Author
115
+ #
111
116
  # Nathaniel Talbott.
112
117
  # Copyright (c) 2000-2003, Nathaniel Talbott
113
118
  #
114
119
  # ----
115
120
  #
116
- # = Usage
121
+ # # Usage
117
122
  #
118
123
  # The general idea behind unit testing is that you write a _test_
119
124
  # _method_ that makes certain _assertions_ about your code, working
@@ -125,7 +130,7 @@ module Test # :nodoc:
125
130
  # pieces.
126
131
  #
127
132
  #
128
- # == Assertions
133
+ # ## Assertions
129
134
  #
130
135
  # These are the heart of the framework. Think of an assertion as a
131
136
  # statement of expected outcome, i.e. "I assert that x should be equal
@@ -137,7 +142,7 @@ module Test # :nodoc:
137
142
  # of the current assertions, see Test::Unit::Assertions.
138
143
  #
139
144
  #
140
- # == Test Method & Test Fixture
145
+ # ## Test Method & Test Fixture
141
146
  #
142
147
  # Obviously, these assertions have to be called within a context that
143
148
  # knows about them and can do something meaningful with their
@@ -197,7 +202,7 @@ module Test # :nodoc:
197
202
  # end
198
203
  #
199
204
  #
200
- # == Test Runners
205
+ # ## Test Runners
201
206
  #
202
207
  # So, now you have this great test class, but you still
203
208
  # need a way to run it and view any failures that occur
@@ -208,10 +213,10 @@ module Test # :nodoc:
208
213
  # runner simply set default test runner ID to
209
214
  # Test::Unit::AutoRunner:
210
215
  #
211
- # require 'test/unit'
212
- # Test::Unit::AutoRunner.default_runner = "gtk2"
216
+ # require 'test/unit'
217
+ # Test::Unit::AutoRunner.default_runner = "gtk2"
213
218
  #
214
- # == Test Suite
219
+ # ## Test Suite
215
220
  #
216
221
  # As more and more unit tests accumulate for a given project, it
217
222
  # becomes a real drag running them one at a time, and it also
@@ -228,17 +233,17 @@ module Test # :nodoc:
228
233
  # 'test/unit'. What does this mean? It means you could
229
234
  # write the above test case like this instead:
230
235
  #
231
- # require 'test/unit'
232
- # require 'test_myfirsttests'
233
- # require 'test_moretestsbyme'
234
- # require 'test_anothersetoftests'
236
+ # require 'test/unit'
237
+ # require 'test_myfirsttests'
238
+ # require 'test_moretestsbyme'
239
+ # require 'test_anothersetoftests'
235
240
  #
236
241
  # Test::Unit is smart enough to find all the test cases existing in
237
242
  # the ObjectSpace and wrap them up into a suite for you. It then runs
238
243
  # the dynamic suite using the console TestRunner.
239
244
  #
240
245
  #
241
- # == Configuration file
246
+ # ## Configuration file
242
247
  #
243
248
  # Test::Unit reads 'test-unit.yml' in the current working
244
249
  # directory as Test::Unit's configuration file. It can
@@ -254,53 +259,58 @@ module Test # :nodoc:
254
259
  #
255
260
  # Here are sample color scheme definitions:
256
261
  #
257
- # color_schemes:
258
- # inverted:
259
- # success:
260
- # name: red
261
- # bold: true
262
- # failure:
263
- # name: green
264
- # bold: true
265
- # other_scheme:
266
- # ...
262
+ # color_schemes:
263
+ # inverted:
264
+ # success:
265
+ # name: red
266
+ # bold: true
267
+ # failure:
268
+ # name: green
269
+ # bold: true
270
+ # other_scheme:
271
+ # ...
267
272
  #
268
273
  # Here are the syntax of color scheme definitions:
269
274
  #
270
- # color_schemes:
271
- # SCHEME_NAME:
272
- # EVENT_NAME:
273
- # name: COLOR_NAME
274
- # intensity: BOOLEAN
275
- # bold: BOOLEAN
276
- # italic: BOOLEAN
277
- # underline: BOOLEAN
278
- # ...
279
- # ...
280
- #
281
- # SCHEME_NAME:: the name of the color scheme
282
- # EVENT_NAME:: one of [success, failure, pending,
283
- # omission, notification, error]
284
- # COLOR_NAME:: one of [black, red, green, yellow, blue,
285
- # magenta, cyan, white]
286
- # BOOLEAN:: true or false
275
+ # color_schemes:
276
+ # SCHEME_NAME:
277
+ # EVENT_NAME:
278
+ # name: COLOR_NAME
279
+ # intensity: BOOLEAN
280
+ # bold: BOOLEAN
281
+ # italic: BOOLEAN
282
+ # underline: BOOLEAN
283
+ # ...
284
+ # ...
285
+ #
286
+ # SCHEME_NAME
287
+ # : the name of the color scheme
288
+ #
289
+ # EVENT_NAME
290
+ # : one of [success, failure, pending, omission, notification, error]
291
+ #
292
+ # COLOR_NAME
293
+ # : one of [black, red, green, yellow, blue, magenta, cyan, white]
294
+ #
295
+ # BOOLEAN
296
+ # : true or false
287
297
  #
288
298
  # You can use the above 'inverted' color scheme with the
289
299
  # following configuration:
290
300
  #
291
- # runner: console
292
- # console_options:
293
- # color_scheme: inverted
294
- # color_schemes:
295
- # inverted:
296
- # success:
297
- # name: red
298
- # bold: true
299
- # failure:
300
- # name: green
301
- # bold: true
301
+ # runner: console
302
+ # console_options:
303
+ # color_scheme: inverted
304
+ # color_schemes:
305
+ # inverted:
306
+ # success:
307
+ # name: red
308
+ # bold: true
309
+ # failure:
310
+ # name: green
311
+ # bold: true
302
312
  #
303
- # == Questions?
313
+ # ## Questions?
304
314
  #
305
315
  # I'd really like to get feedback from all levels of Ruby
306
316
  # practitioners about typos, grammatical errors, unclear statements,
@@ -331,51 +341,53 @@ module Test # :nodoc:
331
341
  # To register multiple hooks, call this method multiple times.
332
342
  #
333
343
  # Here is an example test case:
334
- # Test::Unit.at_start do
335
- # # ...
336
- # end
337
- #
338
- # class TestMyClass1 < Test::Unit::TestCase
339
- # class << self
340
- # def startup
341
- # # ...
342
- # end
343
- # end
344
344
  #
345
- # def setup
345
+ # Test::Unit.at_start do
346
346
  # # ...
347
347
  # end
348
348
  #
349
- # def test_my_class1
350
- # # ...
351
- # end
349
+ # class TestMyClass1 < Test::Unit::TestCase
350
+ # class << self
351
+ # def startup
352
+ # # ...
353
+ # end
354
+ # end
352
355
  #
353
- # def test_my_class2
354
- # # ...
355
- # end
356
- # end
356
+ # def setup
357
+ # # ...
358
+ # end
357
359
  #
358
- # class TestMyClass2 < Test::Unit::TestCase
359
- # class << self
360
- # def startup
360
+ # def test_my_class1
361
361
  # # ...
362
362
  # end
363
- # end
364
363
  #
365
- # def setup
366
- # # ...
364
+ # def test_my_class2
365
+ # # ...
366
+ # end
367
367
  # end
368
368
  #
369
- # def test_my_class1
370
- # # ...
371
- # end
369
+ # class TestMyClass2 < Test::Unit::TestCase
370
+ # class << self
371
+ # def startup
372
+ # # ...
373
+ # end
374
+ # end
372
375
  #
373
- # def test_my_class2
374
- # # ...
376
+ # def setup
377
+ # # ...
378
+ # end
379
+ #
380
+ # def test_my_class1
381
+ # # ...
382
+ # end
383
+ #
384
+ # def test_my_class2
385
+ # # ...
386
+ # end
375
387
  # end
376
- # end
377
388
  #
378
389
  # Here is a call order:
390
+ #
379
391
  # * at_start
380
392
  # * TestMyClass1.startup
381
393
  # * TestMyClass1#setup
@@ -415,51 +427,53 @@ module Test # :nodoc:
415
427
  # To register multiple hooks, call this method multiple times.
416
428
  #
417
429
  # Here is an example test case:
418
- # Test::Unit.at_exit do
419
- # # ...
420
- # end
421
- #
422
- # class TestMyClass1 < Test::Unit::TestCase
423
- # class << self
424
- # def shutdown
425
- # # ...
426
- # end
427
- # end
428
430
  #
429
- # def teardown
431
+ # Test::Unit.at_exit do
430
432
  # # ...
431
433
  # end
432
434
  #
433
- # def test_my_class1
434
- # # ...
435
- # end
435
+ # class TestMyClass1 < Test::Unit::TestCase
436
+ # class << self
437
+ # def shutdown
438
+ # # ...
439
+ # end
440
+ # end
436
441
  #
437
- # def test_my_class2
438
- # # ...
439
- # end
440
- # end
442
+ # def teardown
443
+ # # ...
444
+ # end
441
445
  #
442
- # class TestMyClass2 < Test::Unit::TestCase
443
- # class << self
444
- # def shutdown
446
+ # def test_my_class1
445
447
  # # ...
446
448
  # end
447
- # end
448
449
  #
449
- # def teardown
450
- # # ...
450
+ # def test_my_class2
451
+ # # ...
452
+ # end
451
453
  # end
452
454
  #
453
- # def test_my_class1
454
- # # ...
455
- # end
455
+ # class TestMyClass2 < Test::Unit::TestCase
456
+ # class << self
457
+ # def shutdown
458
+ # # ...
459
+ # end
460
+ # end
456
461
  #
457
- # def test_my_class2
458
- # # ...
462
+ # def teardown
463
+ # # ...
464
+ # end
465
+ #
466
+ # def test_my_class1
467
+ # # ...
468
+ # end
469
+ #
470
+ # def test_my_class2
471
+ # # ...
472
+ # end
459
473
  # end
460
- # end
461
474
  #
462
475
  # Here is a call order:
476
+ #
463
477
  # * TestMyClass1#test_my_class1
464
478
  # * TestMyClass1#teardown
465
479
  # * TestMyClass1#test_my_class2