rubyunit 0.2.11 → 0.2.12

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: bd4a7e6a21dd71254f2b2093200c23aa93b88aa7
4
- data.tar.gz: 58757567b037c730da12117a4a5a83688af22f86
3
+ metadata.gz: fbf27d6a6e8ba4a5897fab6597681d0f111882ee
4
+ data.tar.gz: 138330d193919d74c327d2b30cd2ccdc96610243
5
5
  SHA512:
6
- metadata.gz: 8311455d406a4917c0c97df43cbfad86fd3ef2776570a3307e7f5726d232869a05eae34fa57fbc37a29f0b2e4c2bccdfa79b49c6769880842412d07e2182d9c3
7
- data.tar.gz: eebe4835bf99aa283f2ca8d8f1322c57e4cbac1119cefc8c2f9d2b283f2a0b419f47fdab99ab495fdaffc0f4b973da534844548657ea4ee9262b69516fb57098
6
+ metadata.gz: 0b71cdf88ad315fdcdea0aaa6bed6e839adee6415cb72689078aa19cfe592822ea14ddd133625b880ec688cf0e162147dfd8c386ac2ac3daa1f5c5fe335b7848
7
+ data.tar.gz: 30985acf14c6a098442926676e015a04a1bed99a5d422c2882e43d7cf1ee86b7dce92f80b659ba42d9478b6c60ac77e250c442727164cb8aaae76acdcd078255
@@ -1,6 +1,5 @@
1
1
  module RubyUnit
2
2
  #
3
- # = RubyUnit::AssertionFailure
4
3
  # Exception that is raised when a test assertion fails.
5
4
  #
6
5
  class AssertionFailure < StandardError
@@ -1,4 +1,3 @@
1
-
2
1
  module RubyUnit
3
2
  #
4
3
  # Assertions that can be used by RubyUnit::TestCase
@@ -38,7 +37,7 @@ module RubyUnit
38
37
  # assert false, "This will fail" # => fail
39
38
  #
40
39
  def assert value, message = nil
41
- __assert value, 'Failed to assert that value is false or nil', message, {:value=>value}
40
+ __assert value, 'Failed to assert that value is not false or nil', message, {:value=>value}
42
41
  end
43
42
 
44
43
  #
@@ -214,7 +213,7 @@ module RubyUnit
214
213
  # assertNotKindOf Numeric, 25, 'Nope, try again.' # => fail
215
214
  #
216
215
  def assertNotKindOf exclusion, object, message = nil
217
- __reject (object.is_a? exclusion), 'Object should not be a descendent', message, {:exclusion=>exclusion, :object=>object}
216
+ __reject (object.is_a? exclusion), 'Object should NOT be a descendent', message, {:exclusion=>exclusion, :object=>object}
218
217
  end
219
218
 
220
219
  [:assertNotIsA, :assertIsNotA].each do |method|
@@ -259,6 +258,122 @@ module RubyUnit
259
258
  __reject (object.instance_of? exclusion), 'Object should NOT be this instance', message, {:exclusion=>exclusion, :object=>object}
260
259
  end
261
260
 
261
+ #
262
+ # Assert that an object responds to particular method
263
+ # * raises RubyUnit::AssertionFailure unless _object_ responds to _method_
264
+ #
265
+ # object::
266
+ # The object to check
267
+ #
268
+ # method::
269
+ # The method to assert on the object
270
+ #
271
+ # message::
272
+ # The message provided to be reported for a failure
273
+ #
274
+ # assertRespondTo /^Regexp/, :length, 'It does not, so... no' # => fail
275
+ #
276
+ def assertRespondTo object, method, message = nil
277
+ __assert (object.respond_to? method), 'Failed to assert object responds to method', message, {:object=>object, :method=>method}
278
+ end
279
+
280
+ #
281
+ # Assert that an object does not respond to a particular method
282
+ # * raises RubyUnit::AssertionFailure if _object_ responds to _method_
283
+ #
284
+ # object::
285
+ # The object to check
286
+ #
287
+ # method::
288
+ # The method to assert on the object
289
+ #
290
+ # message::
291
+ # The message provided to be reported for a failure
292
+ #
293
+ # assertNotRespondTo 25, :integer?, 'It does, so close' # => fail
294
+ #
295
+ def assertNotRespondTo object, method, message = nil
296
+ __assert (object.respond_to? method), 'Object should NOT respond to method', message, {:object=>object, :method=>method}
297
+ end
298
+
299
+ #
300
+ # Assert that a collection includes a specified value
301
+ # * raises RubyUnit::AssertionFailure unless _collection_ responds to _value_
302
+ #
303
+ # object::
304
+ # The collection to check
305
+ #
306
+ # method::
307
+ # The value the object should contain
308
+ #
309
+ # message::
310
+ # The message provided to be reported for a failure
311
+ #
312
+ # assertInclude [1, 2], 'not in', 'It does not, so... no' # => fail
313
+ #
314
+ def assertInclude collection, value, message = nil
315
+ assertRespondTo collection, :include?, message
316
+ __assert (collection.include? value), 'Failed to assert collection includes value', message, {:collection=>collection, :value=>value}
317
+ end
318
+
319
+ #
320
+ # Assert that a collection does not include a specified value
321
+ # * raises RubyUnit::AssertionFailure if _collection_ responds to _value_
322
+ #
323
+ # object::
324
+ # The collection to check
325
+ #
326
+ # method::
327
+ # The value the object should not contain
328
+ #
329
+ # message::
330
+ # The message provided to be reported for a failure
331
+ #
332
+ # assertNotInclude [1, 2, 3], 2, 'It does, so close' # => fail
333
+ #
334
+ def assertNotInclude collection, value, message = nil
335
+ assertRespondTo collection, :include?, message
336
+ __reject (collection.include? value), 'Collection should NOT include value', message, {:collection=>collection, :value=>value}
337
+ end
338
+
339
+ #
340
+ # Assert that a class is a descendent of another class
341
+ # * raises RubyUnit::AssertionFailure unless _descendent_ is a descendent of _klass_
342
+ #
343
+ # klass::
344
+ # The parent class
345
+ #
346
+ # descendent::
347
+ # The descendent class
348
+ #
349
+ # message::
350
+ # The message provided to be reported for a failure
351
+ #
352
+ # assertDescendent Numeric, Exception, 'Nope' # => fail
353
+ #
354
+ def assertDescendent klass, descendent, message = nil
355
+ __assert (descendent < klass), 'Failed to assert class heritage', message, {:klass=>klass, :descendent=>descendent}
356
+ end
357
+
358
+ #
359
+ # Assert that a class is not a descendent of another class
360
+ # * raises RubyUnit::AssertionFailure if _illegal_ is a descendent of _klass_
361
+ #
362
+ # klass::
363
+ # The parent class
364
+ #
365
+ # descendent::
366
+ # The illegal descendent class
367
+ #
368
+ # message::
369
+ # The message provided to be reported for a failure
370
+ #
371
+ # assertDescendent StandardError, Exception, 'It is' # => fail
372
+ #
373
+ def assertNotDescendent klass, illegal, message = nil
374
+ __reject (descendent < klass), 'Class should NOT be a descendent', message, {:klass=>klass, :descendent=>descendent}
375
+ end
376
+
262
377
  #
263
378
  # Assert that a constant is defined correctly in the correct class
264
379
  # * raises RubyUnit::AssertionFailure unless the constant is defined in
@@ -450,7 +565,7 @@ module RubyUnit
450
565
  raise ArgumentError, 'Failure message must be String' unless message.nil? or message.is_a? String
451
566
  raise ArgumentError, 'Failure data must be a Hash' unless data.is_a? Hash
452
567
 
453
- error_message = error
568
+ error_message = "\n\n#{error}"
454
569
  error_message << "\n#{message}" if not message.nil?
455
570
  data.each do |index, value|
456
571
  error_message << "\n#{index}:\n\t#{value.inspect}"
@@ -0,0 +1,7 @@
1
+ module RubyUnit
2
+ #
3
+ # Exception that is raised when a test is marked incomplete.
4
+ #
5
+ class IncompleteTest < StandardError
6
+ end
7
+ end
@@ -14,22 +14,28 @@ module RubyUnit
14
14
  # be used, but it's not very far along.
15
15
  #++
16
16
  # The list of Test Cases that have been run are are currently running
17
- @@test_cases = []
17
+ @@test_cases = []
18
18
  # The list of RubyUnit::AssertionFailure exceptions that were caught by the
19
19
  # test runner during testing
20
- @@failures = []
20
+ @@failures = []
21
+ # The list of RubyUnit::SkippedTest exceptions that were caught by the test
22
+ # runner during testing
23
+ @@skips = []
24
+ # The list of RubyUnit::IncompleteTest exceptions that were caught by the test
25
+ # runner during testing
26
+ @@incompletes = []
21
27
  # The list of non RubyUnit::AssertionFailure exceptions that were caught by
22
28
  # the test runner during testing
23
- @@errors = []
29
+ @@errors = []
24
30
  # The total number of tests that have been run
25
- @@tests = 0
31
+ @@tests = 0
26
32
  # The time the tests were started
27
- @@start = nil
33
+ @@start = nil
28
34
  # The time the tests completed
29
- @@finish = nil
35
+ @@finish = nil
30
36
  # Whether or not the test suite still needs to be run. This is used by the
31
37
  # automatic runner to determine if it must be run before the program exits.
32
- @@autorun = true
38
+ @@autorun = true
33
39
 
34
40
  public
35
41
  #
@@ -44,27 +50,29 @@ module RubyUnit
44
50
  @@autorun = false
45
51
  @@start = Time.new
46
52
  runner = new
47
- TestCase.descendents.each do |object|
48
- @@test_cases << object
53
+ TestCase.descendents.each do |test_case|
54
+ @@test_cases << test_case
55
+ object = test_case.new
56
+ test_case.setup
49
57
 
50
- data_methods = object.instance_methods.grep /Data\Z/
51
- test_methods = object.instance_methods.grep /Test\Z/
58
+ data_methods = test_case.instance_methods.grep /Data\Z/
59
+ test_methods = test_case.instance_methods.grep /Test\Z/
52
60
 
53
61
  test_methods.each do |test|
54
62
  data_method = "#{test.slice(0..-5)}Data".to_sym
55
63
  if data_methods.include? data_method
56
- test_case = object.new
57
- data = test_case.send data_method
64
+ data = object.send data_method
58
65
 
59
66
  raise ArgumentError, "Data method #{data_method} must return an array" unless data.is_a? Array
60
67
  data.each do |params|
61
68
  raise ArgumentError, "Data method #{data_method} must return an array of arrays" unless data.is_a? Array
62
- runner.run object, test, params
69
+ runner.run test_case, test, params
63
70
  end
64
71
  else
65
- runner.run object, test
72
+ runner.run test_case, test
66
73
  end
67
74
  end
75
+ test_case.teardown
68
76
  end
69
77
  @@finish = Time.new
70
78
  report unless @@tests.zero?
@@ -100,6 +108,18 @@ module RubyUnit
100
108
  puts error[3].backtrace.join("\n")
101
109
  end
102
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
+
103
123
  puts "#{@@failures.count} Failures:\n" if @@failures.count > 0
104
124
  @@failures.each_with_index do |failure, i|
105
125
  puts "#{i + 1}) #{failure[0]}::#{failure[1]}(#{failure[2]})"
@@ -112,7 +132,8 @@ module RubyUnit
112
132
  puts
113
133
  puts "Tests Complete in #{elapsed} seconds!"
114
134
  puts "%.3f tests/s, %.3f assertions/s" % [(@@tests * inverse).to_f, (TestCase.assertions * inverse).to_f]
115
- puts "%d Tests, %d Assertions, %d Errors, %d Failures" % [@@tests, TestCase.assertions, @@errors.count, @@failures.count]
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]
116
137
  puts
117
138
  end
118
139
  end
@@ -120,12 +141,12 @@ module RubyUnit
120
141
  public
121
142
  #
122
143
  # Run a test and record the results. The test object is instantiated and
123
- # RubyUnit::TestCase.setup is called. RubyUnit::TestCase.teardown is called
124
- # after the test has finished. This is called by the static runner.
144
+ # TestCaseObject.setup is called. TestCaseObject.teardown is called after
145
+ # the test has finished. This is called by the static runner.
125
146
  # * raises ArgumentError unless _params_ is an Array
126
147
  #
127
- # object::
128
- # The test case that has the test
148
+ # test_case_class::
149
+ # The test case class that has the test
129
150
  #
130
151
  # test::
131
152
  # The test that is going to be run
@@ -135,10 +156,9 @@ module RubyUnit
135
156
  #
136
157
  # run TestCaseClass, :myTest, [param1, param2]
137
158
  #
138
- def run object, test, params = []
159
+ def run test_case_class, test, params = []
139
160
  raise ArgumentError, "Parameter list for #{object.class}::#{test} must be an array" unless params.is_a? Array
140
-
141
- test_case = object.new
161
+ test_case = test_case_class.new
142
162
 
143
163
  begin
144
164
  @@tests += 1
@@ -146,6 +166,10 @@ module RubyUnit
146
166
  test_case.send test, *params
147
167
  rescue AssertionFailure => failure
148
168
  @@failures << [test_case.class.name, test, params, failure]
169
+ rescue SkippedTest => skip
170
+ @@skips << [test_case.class.name, test, params, skip]
171
+ rescue IncompleteTest => incomplete
172
+ @@incompletes << [test_case.class.name, test, params, incomplete]
149
173
  rescue Exception => error
150
174
  @@errors << [test_case.class.name, test, params, error]
151
175
  ensure
@@ -0,0 +1,7 @@
1
+ module RubyUnit
2
+ #
3
+ # Exception that is raised when a test is marked skipped.
4
+ #
5
+ class SkippedTest < StandardError
6
+ end
7
+ end
@@ -1,5 +1,7 @@
1
1
  require_relative 'AssertionFailure'
2
2
  require_relative 'Assertions'
3
+ require_relative 'IncompleteTest'
4
+ require_relative 'SkippedTest'
3
5
 
4
6
  module RubyUnit
5
7
  #
@@ -25,9 +27,7 @@ module RubyUnit
25
27
  # end
26
28
  #
27
29
  class TestCase
28
-
29
30
  public
30
-
31
31
  #
32
32
  # The setup helper that is run before each test in the test case.
33
33
  #
@@ -48,12 +48,49 @@ module RubyUnit
48
48
  def teardown
49
49
  end
50
50
 
51
+ #
52
+ # Mark the test as skipped
53
+ #
54
+ # markSkipped 'This test is being refactored'
55
+ #
56
+ def markSkipped message = nil
57
+ raise SkippedTest, message
58
+ end
59
+
60
+ #
61
+ # Mark the test as incomplete
62
+ #
63
+ # markIncomplete 'Implementation of this test is not finished'
64
+ #
65
+ def markIncomplete message = nil
66
+ raise IncompleteTest, message
67
+ end
68
+
51
69
  protected
52
70
  include Assertions
53
71
 
54
72
  class << self
55
73
  public
56
74
  #
75
+ # The setup helper that is run before each test case begins running tests.
76
+ #
77
+ # def self.setup
78
+ # # create objects, set up the scenario
79
+ # end
80
+ #
81
+ def setup
82
+ end
83
+
84
+ #
85
+ # The teardown helper that is run after each test case finishes running tests.
86
+ #
87
+ # def self.teardown
88
+ # # destroy objects, clean up after yourself
89
+ # end
90
+ #
91
+ def teardown
92
+ end
93
+ #
57
94
  # Gets a list of all the descendents of the RubyUnit::TestCase class.
58
95
  # This is important when determining the tests that have been defined.
59
96
  #
data/lib/RubyUnit.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  module RubyUnit
7
7
  # Current RubyUnit version
8
- VERSION = '0.2.11'
8
+ VERSION = '0.2.12'
9
9
 
10
10
  #
11
11
  # RubyUnit::GemInfo contains data and functionality needed by the gem builder
@@ -17,8 +17,8 @@ module RubyUnit
17
17
  Dir['example/*.rb'] + # example files
18
18
  Dir['tests/**/*.rb'] # TESTS
19
19
 
20
- DESCRIPTION = 'Unit testing and test-driven development are crucial parts of' +
21
- 'the software development life cycle. This tool is intended to' +
20
+ DESCRIPTION = 'Unit testing and test-driven development are crucial parts of ' +
21
+ 'the software development life cycle. This tool is intended to ' +
22
22
  'make development and testing in Ruby easier on everyone.'
23
23
  end
24
24
  end
@@ -1,7 +1,13 @@
1
- require 'RubyUnit/TestCase'
1
+ require 'RubyUnit/AssertionFailure'
2
2
 
3
- module RubyUnit
4
- class TEST_AssertionFailure < TestCase
5
-
3
+ #
4
+ # Test Case for RubyUnit::AssertionFailure
5
+ #
6
+ class TEST_AssertionFailure < RubyUnit::TestCase
7
+ #
8
+ # Validate that RubyUnit::AssertionFailure is an Exception
9
+ #
10
+ def isExceptionTest
11
+ assertDescendent Exception, RubyUnit::AssertionFailure, 'AssertionFailure MUST be an Exception!'
6
12
  end
7
13
  end
@@ -1,7 +1,7 @@
1
- require 'RubyUnit/TestCase'
1
+ require 'RubyUnit/Assertions'
2
2
 
3
- module RubyUnit
4
- class TEST_Assertions < TestCase
5
-
6
- end
3
+ #
4
+ # Test Case for RubyUnit::Assertions
5
+ #
6
+ class TEST_Assertions < RubyUnit::TestCase
7
7
  end
@@ -1,27 +1,25 @@
1
1
  require 'RubyUnit'
2
+
3
+ # Data provider for RubyUnit::GemInfo tests
2
4
  require_relative 'data/GemInfo'
3
5
 
4
- module RubyUnit
6
+ #
7
+ # Test Case for the RubyUnit::GemInfo module
8
+ #
9
+ class TEST_GemInfo < RubyUnit::TestCase
10
+ include GemInfoData
11
+
12
+ #
13
+ # Verify that the required constants are defined
14
+ #
15
+ def constantsDefinedTest konstant
16
+ assertConstDefined RubyUnit::GemInfo, konstant, "missing constant in GemInfo: #{konstant}!"
17
+ end
18
+
5
19
  #
6
- # Test for the GemInfo module
20
+ # Verify that the list of files contains the LICENSE file
7
21
  #
8
- module GemInfo
9
- class TEST_GemInfo < TestCase
10
- include GemInfoData
11
-
12
- #
13
- # Verify that the list of required constants is defined
14
- #
15
- def constantsDefinedTest konstant
16
- assertConstDefined RubyUnit::GemInfo, konstant, "missing constant in GemInfo: #{konstant}!"
17
- end
18
-
19
- #
20
- # Verify that the list of files contains the LICENSE file
21
- #
22
- def validateFilesIncludesLicenseTest
23
- assert (RubyUnit::GemInfo::FILES.include? 'LICENSE.md'), 'Gem MUST be distributed with the license!'
24
- end
25
- end
22
+ def validateFilesIncludesLicenseTest
23
+ assertInclude RubyUnit::GemInfo::FILES, 'LICENSE.md', 'Gem MUST be distributed with the license!'
26
24
  end
27
25
  end
@@ -0,0 +1,13 @@
1
+ require 'RubyUnit/IncompleteTest'
2
+
3
+ #
4
+ # Test Case for RubyUnit::IncompleteTest
5
+ #
6
+ class TEST_IncompleteTest < RubyUnit::TestCase
7
+ #
8
+ # Validate that RubyUnit::IncompleteTest is an Exception
9
+ #
10
+ def isExceptionTest
11
+ assertDescendent Exception, RubyUnit::IncompleteTest, 'IncompleteTest MUST be an Exception'
12
+ end
13
+ end
@@ -1,15 +1,13 @@
1
1
  require 'RubyUnit'
2
2
 
3
- module RubyUnit
3
+ #
4
+ # Test Case for the RubyUnit module
5
+ #
6
+ class TEST_RubyUnit < RubyUnit::TestCase
4
7
  #
5
- # Test for the RubyUnit module
8
+ # Verify that the VERSION constant is defined in the RubyUnit module
6
9
  #
7
- class TEST_RubyUnit < TestCase
8
- #
9
- # Verify that the VERSION constant is defined in the RubyUnit module
10
- #
11
- def versionDefinedTest
12
- assertConstDefined RubyUnit, 'VERSION', 'Version must be defined in RubyUnit::VERSION!'
13
- end
10
+ def versionDefinedTest
11
+ assertConstDefined RubyUnit, 'VERSION', 'Version must be defined in RubyUnit::VERSION!'
14
12
  end
15
13
  end
data/tests/TEST_Runner.rb CHANGED
@@ -1,7 +1,7 @@
1
- require 'RubyUnit/TestCase'
1
+ require 'RubyUnit/Runner'
2
2
 
3
- module RubyUnit
4
- class TEST_Runner < TestCase
5
-
6
- end
3
+ #
4
+ # Test Case for the RubyUnit::Runner
5
+ #
6
+ class TEST_Runner < RubyUnit::TestCase
7
7
  end
@@ -0,0 +1,13 @@
1
+ require 'RubyUnit/SkippedTest'
2
+
3
+ #
4
+ # Test Case for RubyUnit::SkippedTest
5
+ #
6
+ class TEST_SkippedTest < RubyUnit::TestCase
7
+ #
8
+ # Validate that RubyUnit::SkippedTest is an Exception
9
+ #
10
+ def isExceptionTest
11
+ assertDescendent Exception, RubyUnit::SkippedTest, 'SkippedTest MUST be an Exception!'
12
+ end
13
+ end
@@ -1,7 +1,122 @@
1
1
  require 'RubyUnit/TestCase'
2
2
 
3
- module RubyUnit
4
- class TEST_TestCase < TestCase
5
-
3
+ # Data provider for RubyUnit::TestCase tests
4
+ require_relative 'data/TestCase'
5
+
6
+ # Fixture for RubyUnit::TestCase tests
7
+ require_relative 'fixture/TestCase'
8
+
9
+ #
10
+ # Test Case for the RubyUnit::TestCase
11
+ #
12
+ class TEST_TestCase < RubyUnit::TestCase
13
+ include TestCaseData
14
+ @setup
15
+ @teardown
16
+
17
+ #
18
+ # Initialize setup and teardown before each test
19
+ #
20
+ def initialize
21
+ super
22
+ @setup = false
23
+ @teardown = false
24
+ end
25
+
26
+ class << self
27
+ # Track whether class setup has been run
28
+ @@setup = false
29
+ # Track whether class teardown has been run
30
+ @@teardown = false
31
+
32
+ #
33
+ # Setup before class
34
+ #
35
+ def setup
36
+ @@setup = true
37
+ end
38
+
39
+ #
40
+ # Teardown after class
41
+ #
42
+ def teardown
43
+ @@teardown = true
44
+ end
45
+ end
46
+
47
+ #
48
+ # Setup before test
49
+ # * self.setup has been run before test begins
50
+ # * self.teardown has not been run before test begins
51
+ # * setup is only run once
52
+ #
53
+ def setup
54
+ assert @@setup, 'setup class method MUST be run before tests begin.'
55
+ assertNot @@teardown, 'teardown class should NOT be run before testing'
56
+ assertNot @setup, 'setup instance method should only be run once'
57
+ @setup = true
58
+ end
59
+
60
+ #
61
+ # Teardown after test
62
+ #
63
+ def teardown
64
+ @teardown = true
65
+ end
66
+
67
+ #
68
+ # Test that the correct class methods are defined
69
+ #
70
+ def classMethodTest method
71
+ assertRespondTo RubyUnit::TestCase, method, 'RubyUnit::TestCase missing class method'
72
+ end
73
+
74
+ #
75
+ # Test that descendents method includes this class
76
+ #
77
+ def descendentsTest
78
+ assertInclude RubyUnit::TestCase.descendents, self.class, 'Should be a descendent of RubyUnit::TestCase'
79
+ end
80
+
81
+ #
82
+ # Test that the correct instance methods are defined
83
+ #
84
+ def instanceMethodTest method
85
+ test_case = TestCaseFixture.new
86
+ assertRespondTo test_case, method, 'Test Case object missing instance method'
87
+ end
88
+
89
+ #
90
+ # Test that setup is run before test
91
+ #
92
+ def setupBeforeTestTest
93
+ assert @setup, 'setup instance method MUST be run before test'
94
+ end
95
+
96
+ #
97
+ # Test that teardown is not run before test
98
+ #
99
+ def noTeardownBeforeTestTest
100
+ assertNot @teardown, 'teardown instance method should NOT be run before test'
101
+ end
102
+
103
+ #
104
+ # Test that markSkipped raises proper exception
105
+ #
106
+ def markSkippedTest
107
+ message = 'markSkipped should raise RubyUnit::SkippedTest'
108
+ assertRaiseExpected RubyUnit::SkippedTest, message, message do
109
+ markSkipped message
110
+ end
111
+ end
112
+
113
+ #
114
+ # Test that markIncomplete raises proper exception
115
+ #
116
+ def markIncompleteTest
117
+ message = 'markIncomplete should raise RubyUnit::IncompleteTest'
118
+ assertRaiseExpected RubyUnit::IncompleteTest, message, message do
119
+ markIncomplete message
120
+ end
6
121
  end
7
122
  end
data/tests/TestSuite.rb CHANGED
@@ -9,11 +9,24 @@ require 'RubyUnit'
9
9
 
10
10
  # Test Cases
11
11
 
12
- # Ruby module => lib/RubyUnit.rb
12
+ # RubyUnit module => RubyUnit.rb
13
13
  require_relative 'TEST_RubyUnit'
14
-
15
- # GemInfo module => lib/RubyUnit.rb
16
14
  require_relative 'TEST_GemInfo'
17
15
 
18
- # TestCase class => lib/RubyUnit/TestCase.rb
16
+ # AssertionFailure exception => RubyUnit/AssertionFailure.rb
17
+ require_relative 'TEST_AssertionFailure'
18
+
19
+ # Assertions module => RubyUnit/Assertions.rb
20
+ require_relative 'TEST_Assertions'
21
+
22
+ # IncompleteTest exception => RubyUnit/IncompleteTest.rb
23
+ require_relative 'TEST_IncompleteTest'
24
+
25
+ # Runner class => RubyUnit/Runner.rb
26
+ require_relative 'TEST_Runner'
27
+
28
+ # SkippedTest exception => RubyUnit/SkippedTest.rb
29
+ require_relative 'TEST_SkippedTest'
30
+
31
+ # TestCase class => RubyUnit/TestCase.rb
19
32
  require_relative 'TEST_TestCase'
@@ -1,3 +1,6 @@
1
+ #
2
+ # Data provider for RubyUnit::GemInfo module Test Case
3
+ #
1
4
  module GemInfoData
2
5
  def constantsDefinedData
3
6
  [
@@ -1,3 +1,22 @@
1
+ #
2
+ # Data provider for RubyUnit::TestCase class Test Case
3
+ #
1
4
  module TestCaseData
2
-
5
+ def classMethodData
6
+ [
7
+ [ :setup],
8
+ [ :teardown],
9
+ [:descendents],
10
+ [ :assertions],
11
+ ]
12
+ end
13
+
14
+ def instanceMethodData
15
+ [
16
+ [ :setup],
17
+ [ :teardown],
18
+ [ :markSkipped],
19
+ [ :markIncomplete],
20
+ ]
21
+ end
3
22
  end
@@ -0,0 +1,6 @@
1
+ #
2
+ # Fixture for RubyUnit::TestCase tests
3
+ #
4
+ class TestCaseFixture < RubyUnit::TestCase
5
+ # This is a fixture, NO TESTS
6
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
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-15 00:00:00.000000000 Z
11
+ date: 2014-10-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Unit testing and test-driven development are crucial parts ofthe software
14
- development life cycle. This tool is intended tomake development and testing in
13
+ description: Unit testing and test-driven development are crucial parts of the software
14
+ development life cycle. This tool is intended to make development and testing in
15
15
  Ruby easier on everyone.
16
16
  email:
17
17
  - matthewclower@gmail.com
@@ -29,22 +29,27 @@ files:
29
29
  - lib/RubyUnit.rb
30
30
  - lib/RubyUnit/AssertionFailure.rb
31
31
  - lib/RubyUnit/Assertions.rb
32
+ - lib/RubyUnit/IncompleteTest.rb
32
33
  - lib/RubyUnit/Runner.rb
34
+ - lib/RubyUnit/SkippedTest.rb
33
35
  - lib/RubyUnit/TestCase.rb
34
36
  - tests/TEST_AssertionFailure.rb
35
37
  - tests/TEST_Assertions.rb
36
38
  - tests/TEST_GemInfo.rb
39
+ - tests/TEST_IncompleteTest.rb
37
40
  - tests/TEST_RubyUnit.rb
38
41
  - tests/TEST_Runner.rb
42
+ - tests/TEST_SkippedTest.rb
39
43
  - tests/TEST_TestCase.rb
40
44
  - tests/TestSuite.rb
41
45
  - tests/data/GemInfo.rb
42
46
  - tests/data/TestCase.rb
47
+ - tests/fixture/TestCase.rb
43
48
  homepage: http://github.com/RubyUnit/RubyUnit
44
49
  licenses:
45
50
  - Ruby
46
51
  metadata:
47
- Issue Tracker: https://github.com/RubyUnit/RubyUnit/issues
52
+ Issue_Tracker: https://github.com/RubyUnit/RubyUnit/issues
48
53
  post_install_message: Happy Testing!
49
54
  rdoc_options:
50
55
  - "--all"