rubyunit 0.2.14 → 0.3.15

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -5
  3. data/TestSuite.rb +7 -23
  4. data/lib/RubyUnit/AssertionFailure.rb +9 -9
  5. data/lib/RubyUnit/AssertionMessage.rb +70 -0
  6. data/lib/RubyUnit/Assertions/Basic.rb +121 -0
  7. data/lib/RubyUnit/Assertions/Class.rb +196 -0
  8. data/lib/RubyUnit/Assertions/Collection.rb +80 -0
  9. data/lib/RubyUnit/Assertions/Comparison.rb +200 -0
  10. data/lib/RubyUnit/Assertions/Exception.rb +105 -0
  11. data/lib/RubyUnit/Assertions/Method.rb +157 -0
  12. data/lib/RubyUnit/Assertions.rb +9 -636
  13. data/lib/RubyUnit/Runner.rb +1 -2
  14. data/lib/RubyUnit.rb +28 -4
  15. data/tests/AssertionFailure/TC_Class.rb +2 -13
  16. data/tests/AssertionFailure/TC_Instance.rb +1 -1
  17. data/tests/AssertionFailure/data/Instance.rb +3 -3
  18. data/tests/AssertionMessage/TC_Constant.rb +20 -0
  19. data/tests/AssertionMessage/data/Constant.rb +70 -0
  20. data/tests/Assertions/TC_Basic.rb +349 -0
  21. data/tests/Assertions/TC_Class.rb +75 -0
  22. data/tests/Assertions/TC_Comparison.rb +13 -0
  23. data/tests/Assertions/data/Basic.rb +90 -0
  24. data/tests/Assertions/data/Class.rb +54 -0
  25. data/tests/Assertions/data/Comparison.rb +7 -0
  26. data/tests/Assertions/data/ObjectTypes.rb +174 -0
  27. data/tests/IncompleteTest/TC_IncompleteTest.rb +15 -0
  28. data/tests/RubyUnit/TC_RubyUnit.rb +30 -0
  29. data/tests/RubyUnit/data/RubyUnit.rb +16 -0
  30. data/tests/Runner/TC_Runner.rb +9 -0
  31. data/tests/SkippedTest/TC_SkippedTest.rb +15 -0
  32. data/tests/TS_AssertionFailure.rb +4 -2
  33. data/tests/TS_AssertionMessage.rb +9 -0
  34. data/tests/TS_Assertions.rb +67 -0
  35. data/tests/TS_IncompleteTest.rb +9 -0
  36. data/tests/TS_RubyUnit.rb +4 -2
  37. data/tests/TS_Runner.rb +9 -0
  38. data/tests/TS_SkippedTest.rb +9 -0
  39. data/tests/TS_TestCase.rb +9 -0
  40. data/tests/TestCase/TC_TestCase.rb +120 -0
  41. data/tests/TestCase/data/TestCase.rb +24 -0
  42. metadata +32 -12
  43. data/tests/AssertionFailure/data/Class.rb +0 -12
  44. data/tests/TEST_Assertions.rb +0 -37
  45. data/tests/TEST_IncompleteTest.rb +0 -13
  46. data/tests/TEST_Runner.rb +0 -7
  47. data/tests/TEST_SkippedTest.rb +0 -13
  48. data/tests/TEST_TestCase.rb +0 -122
  49. data/tests/data/Assertions.rb +0 -23
  50. data/tests/data/TestCase.rb +0 -22
  51. data/tests/fixture/TestCase.rb +0 -6
data/lib/RubyUnit.rb CHANGED
@@ -4,8 +4,31 @@
4
4
  # The RubyModule is the root object for all RubyUnit modules and classes.
5
5
  #
6
6
  module RubyUnit
7
+ # Debug mode
8
+ @@debug = false
9
+ INVALID_DEBUG_MODE = 'Debug mode must be Boolean'
10
+
7
11
  # Current RubyUnit version
8
- VERSION = '0.2.14'
12
+ VERSION = '0.3.15'
13
+
14
+ #
15
+ # Set debug mode
16
+ # * raises ArgumentError if _bool_ is not a Boolean
17
+ #
18
+ # bool::
19
+ # New value for debug mode
20
+ #
21
+ def self.debug= bool
22
+ raise ArgumentError, INVALID_DEBUG_MODE unless [true, false].include? bool
23
+ @@debug = bool
24
+ end
25
+
26
+ #
27
+ # Get the current debug mode
28
+ #
29
+ def self.debug
30
+ @@debug
31
+ end
9
32
 
10
33
  #
11
34
  # RubyUnit::GemInfo contains data and functionality needed by the gem builder
@@ -18,9 +41,10 @@ module RubyUnit
18
41
  ['TestSuite.rb'] + # Test Suite
19
42
  Dir['tests/**/*.rb'] # TESTS
20
43
 
21
- DESCRIPTION = 'Unit testing and test-driven development are crucial parts of ' +
22
- 'the software development life cycle. This tool is intended to ' +
23
- 'make development and testing in Ruby easier on everyone.'
44
+ DESCRIPTION = 'Unit testing and test-driven development are crucial parts of ' +
45
+ 'the software development life cycle. This tool is intended to ' +
46
+ 'make development and testing in Ruby easier on everyone. RubyUnit ' +
47
+ 'is also designed to with a focus on data-driven testing.'
24
48
  end
25
49
  end
26
50
 
@@ -1,27 +1,16 @@
1
1
  require 'RubyUnit/AssertionFailure'
2
2
 
3
- # Data provider for RubyUnit::AssertionFailure tests
4
- require_relative 'data/Class'
5
-
6
3
  module AssertionFailureTests
7
- #
4
+ ##
8
5
  # Test Case for RubyUnit::AssertionFailure
9
6
  #
10
7
  class TC_Class < RubyUnit::TestCase
11
- include ClassTestsData
12
8
 
13
- #
9
+ ##
14
10
  # Validate that RubyUnit::AssertionFailure is an Exception
15
11
  #
16
12
  def isExceptionTest
17
13
  assertDescendent Exception, RubyUnit::AssertionFailure, 'AssertionFailure MUST be an Exception'
18
14
  end
19
-
20
- #
21
- # Assert all required constants are defined
22
- #
23
- def constantTest konstant
24
- assertConstDefined RubyUnit::AssertionFailure, konstant, 'Required constant is missing'
25
- end
26
15
  end
27
16
  end
@@ -8,7 +8,7 @@ module AssertionFailureTests
8
8
  # Test Case for RubyUnit::AssertionFailure
9
9
  #
10
10
  class TC_Instance < RubyUnit::TestCase
11
- include InstanceTestsData
11
+ include InstanceData
12
12
 
13
13
  #
14
14
  # Test creation of default AssertionFailure
@@ -2,12 +2,12 @@ module AssertionFailureTests
2
2
  #
3
3
  # Data provider for RubyUnit::AssertionFailure class Test Case
4
4
  #
5
- module InstanceTestsData
5
+ module InstanceData
6
6
  def dataData
7
+ infoData +
7
8
  [
8
9
  [{}],
9
- ] +
10
- infoData
10
+ ]
11
11
  end
12
12
 
13
13
  def infoData
@@ -0,0 +1,20 @@
1
+ require 'RubyUnit/AssertionMessage'
2
+
3
+ # Data provider for RubyUnit::AssertionFailure tests
4
+ require_relative 'data/Constant'
5
+
6
+ module AssertionMessageTests
7
+ ##
8
+ # Test Case for RubyUnit::AssertionFailure
9
+ #
10
+ class TC_Constant < RubyUnit::TestCase
11
+ include ConstantData
12
+
13
+ ##
14
+ # Assert all required constants are defined
15
+ #
16
+ def constantTest konstant
17
+ assertConstDefined RubyUnit::AssertionFailure, konstant, 'Required constant is missing'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,70 @@
1
+ module AssertionMessageTests
2
+ #
3
+ # Data provider for RubyUnit::AssertionFailure class Test Case
4
+ #
5
+ module ConstantData
6
+ def constantData
7
+ [
8
+ ##
9
+ # Baisc assertion messages
10
+ [ 'FAILING'],
11
+ [ 'ASSERT_ERROR'],
12
+ [ 'ASSERT_NOT_ERROR'],
13
+ [ 'ASSERT_TRUE_ERROR'],
14
+ [ 'ASSERT_FALSE_ERROR'],
15
+ [ 'ASSERT_NIL_ERROR'],
16
+ ['ASSERT_NOT_NIL_ERROR'],
17
+
18
+ ##
19
+ # Class assertion messages
20
+ [ 'ASSERT_KIND_OF_ERROR'],
21
+ [ 'ASSERT_NOT_KIND_OF_ERROR'],
22
+ [ 'ASSERT_INSTANCE_OF_ERROR'],
23
+ [ 'ASSERT_NOT_INSTANCE_OF_ERROR'],
24
+ [ 'ASSERT_DESCENDENT_ERROR'],
25
+ [ 'ASSERT_NOT_DESCENDENT_ERROR'],
26
+ [ 'ASSERT_CONST_ERROR'],
27
+ [ 'ASSERT_CONST_DEFINED_ERROR'],
28
+ ['ASSERT_CONST_NOT_DEFINED_ERROR'],
29
+
30
+ ##
31
+ # Collection assertion messages
32
+ [ 'ASSERT_INCLUDE_ERROR'],
33
+ [ 'ASSERT_NOT_INCLUDE_ERROR'],
34
+ [ 'ASSERT_EMPTY_ERROR'],
35
+ [ 'ASSERT_NOT_EMPTY_ERROR'],
36
+
37
+ ##
38
+ # Comparison assertion messages
39
+ [ 'ASSERT_EQUAL_ERROR'],
40
+ [ 'ASSERT_NOT_EQUAL_ERROR'],
41
+ [ 'ASSERT_GREATERTHAN_ERROR'],
42
+ ['ASSERT_GREATERTHANOREQUAL_ERROR'],
43
+ [ 'ASSERT_LESSTHAN_ERROR'],
44
+ [ 'ASSERT_LESSTHANOREQUAL_ERROR'],
45
+ [ 'ASSERT_MATCH_ERROR'],
46
+ [ 'ASSERT_NOT_MATCH_ERROR'],
47
+ [ 'ASSERT_SAME_ERROR'],
48
+ [ 'ASSERT_NOT_SAME_ERROR'],
49
+
50
+ ##
51
+ # Exception assertion messages
52
+ ['ASSERT_NOTHING_RAISED_ERROR'],
53
+ [ 'ASSERT_RAISE_MESSAGE_ERROR'],
54
+ [ 'ASSERT_RAISE_KIND_OF_ERROR'],
55
+ ['ASSERT_RAISE_EXPECTED_ERROR'],
56
+
57
+ ##
58
+ # Method assertion messages
59
+ [ 'ASSERT_RESPOND_TO_ERROR'],
60
+ [ 'ASSERT_NOT_RESPOND_TO_ERROR'],
61
+ [ 'ASSERT_METHOD_ERROR'],
62
+ [ 'ASSERT_NOT_METHOD_ERROR'],
63
+ [ 'ASSERT_INSTANCE_METHOD_ERROR'],
64
+ ['ASSERT_NOT_INSTANCE_METHOD_ERROR'],
65
+ [ 'ASSERT_CLASS_METHOD_ERROR'],
66
+ [ 'ASSERT_NOT_CLASS_METHOD_ERROR'],
67
+ ]
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,349 @@
1
+ require 'RubyUnit/Assertions'
2
+
3
+ # Data provider for RubyUnit::TestCase tests
4
+ require_relative 'data/Basic'
5
+
6
+ module AssertionsTests
7
+ ##
8
+ # Test Case for RubyUnit::Assertions Basic assertions
9
+ #
10
+ class TC_Basic < AssertionsTestCase
11
+ include BasicData
12
+
13
+ ##
14
+ # Test for default fail
15
+ #
16
+ def defaultFailTest
17
+ rescue_assertion /#{FAILING}/ do
18
+ fail
19
+ end
20
+ end
21
+
22
+ ##
23
+ # Test fail with message
24
+ #
25
+ # message::
26
+ # The assertion message
27
+ #
28
+ def failWithMessageTest message
29
+ rescue_assertion /#{FAILING}/, message do
30
+ fail message
31
+ end
32
+ end
33
+
34
+ ##
35
+ # Test fail with message and data
36
+ #
37
+ # message::
38
+ # The assertion message
39
+ #
40
+ # data::
41
+ # The assertion data
42
+ #
43
+ def failWithDataTest message, data = {}
44
+ rescue_assertion /#{FAILING}/, message do
45
+ fail message, data
46
+ end
47
+ end
48
+
49
+ ##
50
+ # Test assert
51
+ #
52
+ # value::
53
+ # The value to assert
54
+ #
55
+ def assertTest value
56
+ assert value
57
+ end
58
+
59
+ ##
60
+ # Test assert with message
61
+ #
62
+ # value::
63
+ # The value to assert
64
+ #
65
+ # message::
66
+ # The assertion message
67
+ #
68
+ def assertWithMessageTest value, message
69
+ assert value, message
70
+ end
71
+
72
+ ##
73
+ # Test assert failure
74
+ #
75
+ # value::
76
+ # The value to assert
77
+ #
78
+ def assertFailTest value
79
+ rescue_assertion /#{ASSERT_ERROR}/ do
80
+ assert value
81
+ end
82
+ end
83
+
84
+ ##
85
+ # Test assert failure with message
86
+ #
87
+ # value::
88
+ # The value to assert
89
+ #
90
+ # message::
91
+ # The assertion message
92
+ #
93
+ def assertFailWithMessageTest value, message
94
+ rescue_assertion /#{ASSERT_ERROR}/, message do
95
+ assert value, message
96
+ end
97
+ end
98
+
99
+ ##
100
+ # Test assertNot
101
+ #
102
+ # value::
103
+ # The value to assert
104
+ #
105
+ def assertNotTest value
106
+ assertNot value
107
+ end
108
+
109
+ ##
110
+ # Test assertNot with message
111
+ #
112
+ # value::
113
+ # The value to assert
114
+ #
115
+ # message::
116
+ # The assertion message
117
+ #
118
+ def assertNotWithMessageTest value, message
119
+ assertNot value, message
120
+ end
121
+
122
+ ##
123
+ # Test assertNot failure
124
+ #
125
+ # value::
126
+ # The value to assert
127
+ #
128
+ def assertNotFailTest value
129
+ rescue_assertion /#{ASSERT_NOT_ERROR}/ do
130
+ assertNot value
131
+ end
132
+ end
133
+
134
+ ##
135
+ # Test assertNot failure with message
136
+ #
137
+ # value::
138
+ # The value to assert
139
+ #
140
+ # message::
141
+ # The assertion message
142
+ #
143
+ def assertNotFailWithMessageTest value, message
144
+ rescue_assertion /#{ASSERT_NOT_ERROR}/, message do
145
+ assertNot value, message
146
+ end
147
+ end
148
+
149
+ ##
150
+ # Test assertTrue
151
+ #
152
+ # value::
153
+ # The value to assert
154
+ #
155
+ def assertTrueTest value
156
+ assertTrue value
157
+ end
158
+
159
+ ##
160
+ # Test assertTrue with message
161
+ #
162
+ # value::
163
+ # The value to assert
164
+ #
165
+ # message::
166
+ # The assertion message
167
+ #
168
+ def assertTrueWithMessageTest value, message
169
+ assertTrue value, message
170
+ end
171
+
172
+ ##
173
+ # Test assertTrue failure
174
+ #
175
+ # value::
176
+ # The value to assert
177
+ #
178
+ def assertTrueFailTest value
179
+ rescue_assertion /#{ASSERT_TRUE_ERROR}/ do
180
+ assertTrue value
181
+ end
182
+ end
183
+
184
+ ##
185
+ # Test assertTrue failure with message
186
+ #
187
+ # value::
188
+ # The value to assert
189
+ #
190
+ # message::
191
+ # The assertion message
192
+ #
193
+ def assertTrueFailWithMessageTest value, message
194
+ rescue_assertion /#{ASSERT_TRUE_ERROR}/, message do
195
+ assertTrue value, message
196
+ end
197
+ end
198
+
199
+ ##
200
+ # Test assertFalse
201
+ #
202
+ # value::
203
+ # The value to assert
204
+ #
205
+ def assertFalseTest value
206
+ assertFalse value
207
+ end
208
+
209
+ ##
210
+ # Test assertFalse with message
211
+ #
212
+ # value::
213
+ # The value to assert
214
+ #
215
+ # message::
216
+ # The assertion message
217
+ #
218
+ def assertFalseWithMessageTest value, message
219
+ assertFalse value, message
220
+ end
221
+
222
+ ##
223
+ # Test assertFalse failure
224
+ #
225
+ # value::
226
+ # The value to assert
227
+ #
228
+ def assertFalseFailTest value
229
+ rescue_assertion /#{ASSERT_FALSE_ERROR}/ do
230
+ assertFalse value
231
+ end
232
+ end
233
+
234
+ ##
235
+ # Test assertFalse failure with message
236
+ #
237
+ # value::
238
+ # The value to assert
239
+ #
240
+ # message::
241
+ # The assertion message
242
+ #
243
+ def assertFalseFailWithMessageTest value, message
244
+ rescue_assertion /#{ASSERT_FALSE_ERROR}/, message do
245
+ assertFalse value, message
246
+ end
247
+ end
248
+
249
+ ##
250
+ # Test assertNil
251
+ #
252
+ # value::
253
+ # The value to assert
254
+ #
255
+ def assertNilTest value
256
+ assertNil value
257
+ end
258
+
259
+ ##
260
+ # Test assertNil with message
261
+ #
262
+ # value::
263
+ # The value to assert
264
+ #
265
+ # message::
266
+ # The assertion message
267
+ #
268
+ def assertNilWithMessageTest value, message
269
+ assertNil value, message
270
+ end
271
+
272
+ ##
273
+ # Test assertNil failure
274
+ #
275
+ # value::
276
+ # The value to assert
277
+ #
278
+ def assertNilFailTest value
279
+ rescue_assertion /#{ASSERT_NIL_ERROR}/ do
280
+ assertNil value
281
+ end
282
+ end
283
+
284
+ ##
285
+ # Test assertNil failure with message
286
+ #
287
+ # value::
288
+ # The value to assert
289
+ #
290
+ # message::
291
+ # The assertion message
292
+ #
293
+ def assertNilFailWithMessageTest value, message
294
+ rescue_assertion /#{ASSERT_NIL_ERROR}/, message do
295
+ assertNil value, message
296
+ end
297
+ end
298
+
299
+ ##
300
+ # Test assertNotNil
301
+ #
302
+ # value::
303
+ # The value to assert
304
+ #
305
+ def assertNotNilTest value
306
+ assertNotNil value
307
+ end
308
+
309
+ ##
310
+ # Test assertNotNil with message
311
+ #
312
+ # value::
313
+ # The value to assert
314
+ #
315
+ # message::
316
+ # The assertion message
317
+ #
318
+ def assertNotNilWithMessageTest value, message
319
+ assertNotNil value, message
320
+ end
321
+
322
+ ##
323
+ # Test assertNotNil failure
324
+ #
325
+ # value::
326
+ # The value to assert
327
+ #
328
+ def assertNotNilFailTest value
329
+ rescue_assertion /#{ASSERT_NOT_NIL_ERROR}/ do
330
+ assertNotNil value
331
+ end
332
+ end
333
+
334
+ ##
335
+ # Test assertNotNil failure with message
336
+ #
337
+ # value::
338
+ # The value to assert
339
+ #
340
+ # message::
341
+ # The assertion message
342
+ #
343
+ def assertNotNilFailWithMessageTest value, message
344
+ rescue_assertion /#{ASSERT_NOT_NIL_ERROR}/, message do
345
+ assertNotNil value, message
346
+ end
347
+ end
348
+ end
349
+ end
@@ -0,0 +1,75 @@
1
+ require 'RubyUnit/Assertions'
2
+
3
+ # Data provider for RubyUnit::TestCase tests
4
+ require_relative 'data/Class'
5
+
6
+ module AssertionsTests
7
+ ##
8
+ # Test Case for RubyUnit::Assertions Class assertions
9
+ #
10
+ class TC_Class < AssertionsTestCase
11
+ include ClassData
12
+
13
+ ##
14
+ # Test assertKindOf
15
+ #
16
+ # klass::
17
+ # Class name for assertion
18
+ #
19
+ # object::
20
+ # Object to be asserted
21
+ #
22
+ def assertKindOfTest klass, object
23
+ assertKindOf klass, object
24
+ end
25
+
26
+ ##
27
+ # Test assertKindOf failure
28
+ #
29
+ # klass::
30
+ # Class name for assertion
31
+ #
32
+ # object::
33
+ # Object to be asserted
34
+ #
35
+ def assertKindOfFailTest klass, object
36
+ rescue_assertion /#{ASSERT_KIND_OF_ERROR}/ do
37
+ assertKindOf klass, object
38
+ end
39
+ end
40
+
41
+ ##
42
+ # Test assertKindOf with message
43
+ #
44
+ # klass::
45
+ # Class name for assertion
46
+ #
47
+ # object::
48
+ # Object to be asserted
49
+ #
50
+ # message::
51
+ # The assertion message
52
+ #
53
+ def assertKindOfWithMessageTest klass, object, message
54
+ assertKindOf klass, object, message
55
+ end
56
+
57
+ ##
58
+ # Test assertKindOf failure
59
+ #
60
+ # klass::
61
+ # Class name for assertion
62
+ #
63
+ # object::
64
+ # Object to be asserted
65
+ #
66
+ # message::
67
+ # The assertion message
68
+ #
69
+ def assertKindOfWithMessageFailTest klass, object, message
70
+ rescue_assertion /#{ASSERT_KIND_OF_ERROR}/, message do
71
+ assertKindOf klass, object, message
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,13 @@
1
+ require 'RubyUnit/Assertions'
2
+
3
+ # Data provider for RubyUnit::TestCase tests
4
+ require_relative 'data/Comparison'
5
+
6
+ module AssertionsTests
7
+ #
8
+ # Test Case for RubyUnit::Assertions Comparison assertions
9
+ #
10
+ class TC_Comparison < AssertionsTestCase
11
+ include ComparisonData
12
+ end
13
+ end