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.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/TestSuite.rb +7 -23
- data/lib/RubyUnit/AssertionFailure.rb +9 -9
- data/lib/RubyUnit/AssertionMessage.rb +70 -0
- data/lib/RubyUnit/Assertions/Basic.rb +121 -0
- data/lib/RubyUnit/Assertions/Class.rb +196 -0
- data/lib/RubyUnit/Assertions/Collection.rb +80 -0
- data/lib/RubyUnit/Assertions/Comparison.rb +200 -0
- data/lib/RubyUnit/Assertions/Exception.rb +105 -0
- data/lib/RubyUnit/Assertions/Method.rb +157 -0
- data/lib/RubyUnit/Assertions.rb +9 -636
- data/lib/RubyUnit/Runner.rb +1 -2
- data/lib/RubyUnit.rb +28 -4
- data/tests/AssertionFailure/TC_Class.rb +2 -13
- data/tests/AssertionFailure/TC_Instance.rb +1 -1
- data/tests/AssertionFailure/data/Instance.rb +3 -3
- data/tests/AssertionMessage/TC_Constant.rb +20 -0
- data/tests/AssertionMessage/data/Constant.rb +70 -0
- data/tests/Assertions/TC_Basic.rb +349 -0
- data/tests/Assertions/TC_Class.rb +75 -0
- data/tests/Assertions/TC_Comparison.rb +13 -0
- data/tests/Assertions/data/Basic.rb +90 -0
- data/tests/Assertions/data/Class.rb +54 -0
- data/tests/Assertions/data/Comparison.rb +7 -0
- data/tests/Assertions/data/ObjectTypes.rb +174 -0
- data/tests/IncompleteTest/TC_IncompleteTest.rb +15 -0
- data/tests/RubyUnit/TC_RubyUnit.rb +30 -0
- data/tests/RubyUnit/data/RubyUnit.rb +16 -0
- data/tests/Runner/TC_Runner.rb +9 -0
- data/tests/SkippedTest/TC_SkippedTest.rb +15 -0
- data/tests/TS_AssertionFailure.rb +4 -2
- data/tests/TS_AssertionMessage.rb +9 -0
- data/tests/TS_Assertions.rb +67 -0
- data/tests/TS_IncompleteTest.rb +9 -0
- data/tests/TS_RubyUnit.rb +4 -2
- data/tests/TS_Runner.rb +9 -0
- data/tests/TS_SkippedTest.rb +9 -0
- data/tests/TS_TestCase.rb +9 -0
- data/tests/TestCase/TC_TestCase.rb +120 -0
- data/tests/TestCase/data/TestCase.rb +24 -0
- metadata +32 -12
- data/tests/AssertionFailure/data/Class.rb +0 -12
- data/tests/TEST_Assertions.rb +0 -37
- data/tests/TEST_IncompleteTest.rb +0 -13
- data/tests/TEST_Runner.rb +0 -7
- data/tests/TEST_SkippedTest.rb +0 -13
- data/tests/TEST_TestCase.rb +0 -122
- data/tests/data/Assertions.rb +0 -23
- data/tests/data/TestCase.rb +0 -22
- data/tests/fixture/TestCase.rb +0 -6
@@ -0,0 +1,90 @@
|
|
1
|
+
require_relative 'ObjectTypes'
|
2
|
+
|
3
|
+
module AssertionsTests
|
4
|
+
#
|
5
|
+
# Data provider for RubyUnit::Assertions Basic assertions
|
6
|
+
#
|
7
|
+
module BasicData
|
8
|
+
include ObjectTypes
|
9
|
+
|
10
|
+
def failWithMessageData
|
11
|
+
AssertionsTests::MESSAGES
|
12
|
+
end
|
13
|
+
|
14
|
+
def failWithDataData
|
15
|
+
add_parameter AssertionsTests::MESSAGES, hashObjects
|
16
|
+
end
|
17
|
+
|
18
|
+
def assertData
|
19
|
+
trueObjects + basicObjects
|
20
|
+
end
|
21
|
+
alias_method :assertNotFailData, :assertData
|
22
|
+
|
23
|
+
def assertWithMessageData
|
24
|
+
add_parameter assertData
|
25
|
+
end
|
26
|
+
alias_method :assertNotFailWithMessageData, :assertWithMessageData
|
27
|
+
|
28
|
+
def assertFailData
|
29
|
+
falseObjects + nilObjects
|
30
|
+
end
|
31
|
+
alias_method :assertNotData, :assertFailData
|
32
|
+
|
33
|
+
def assertFailWithMessageData
|
34
|
+
add_parameter assertFailData
|
35
|
+
end
|
36
|
+
alias_method :assertNotWithMessageData, :assertFailWithMessageData
|
37
|
+
|
38
|
+
def assertTrueData
|
39
|
+
trueObjects
|
40
|
+
end
|
41
|
+
|
42
|
+
def assertTrueWithMessageData
|
43
|
+
add_parameter assertTrueData
|
44
|
+
end
|
45
|
+
|
46
|
+
def assertTrueFailData
|
47
|
+
falseObjects + nilObjects + basicObjects
|
48
|
+
end
|
49
|
+
|
50
|
+
def assertTrueFailWithMessageData
|
51
|
+
add_parameter assertTrueFailData
|
52
|
+
end
|
53
|
+
|
54
|
+
def assertFalseData
|
55
|
+
falseObjects
|
56
|
+
end
|
57
|
+
|
58
|
+
def assertFalseWithMessageData
|
59
|
+
add_parameter assertFalseData
|
60
|
+
end
|
61
|
+
|
62
|
+
def assertFalseFailData
|
63
|
+
trueObjects + basicObjects + nilObjects
|
64
|
+
end
|
65
|
+
|
66
|
+
def assertFalseFailWithMessageData
|
67
|
+
add_parameter assertFalseFailData
|
68
|
+
end
|
69
|
+
|
70
|
+
def assertNilData
|
71
|
+
nilObjects
|
72
|
+
end
|
73
|
+
alias_method :assertNotNilFailData, :assertNilData
|
74
|
+
|
75
|
+
def assertNilWithMessageData
|
76
|
+
add_parameter assertNilData
|
77
|
+
end
|
78
|
+
alias_method :assertNotNilFailWithMessageData, :assertNilWithMessageData
|
79
|
+
|
80
|
+
def assertNilFailData
|
81
|
+
trueObjects + basicObjects + falseObjects
|
82
|
+
end
|
83
|
+
alias_method :assertNotNilData, :assertNilFailData
|
84
|
+
|
85
|
+
def assertNilFailWithMessageData
|
86
|
+
add_parameter assertNilFailData
|
87
|
+
end
|
88
|
+
alias_method :assertNotNilWithMessageData, :assertNilFailWithMessageData
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative 'ObjectTypes'
|
2
|
+
|
3
|
+
module AssertionsTests
|
4
|
+
##
|
5
|
+
# Data provider for RubyUnit::Assertions Class assertions
|
6
|
+
#
|
7
|
+
module ClassData
|
8
|
+
include ObjectTypes
|
9
|
+
|
10
|
+
def assertKindOfData
|
11
|
+
data = add_parameter [[Class]], classObjects
|
12
|
+
data += add_parameter [[NilClass]], nilObjects
|
13
|
+
data += add_parameter [[TrueClass]], trueObjects
|
14
|
+
data += add_parameter [[FalseClass]], falseObjects
|
15
|
+
data += add_parameter [[Numeric], [Integer], [Fixnum]], fixnumObjects
|
16
|
+
data += add_parameter [[Numeric], [Integer], [Bignum]], bignumObjects
|
17
|
+
data += add_parameter [[Numeric], [Float]], floatObjects
|
18
|
+
data += add_parameter [[Numeric], [Rational]], rationalObjects
|
19
|
+
data += add_parameter [[Numeric], [Complex]], complexObjects
|
20
|
+
data += add_parameter [[Time]], timeObjects
|
21
|
+
data += add_parameter [[String]], stringObjects
|
22
|
+
data += add_parameter [[Range]], rangeObjects
|
23
|
+
data += add_parameter [[Regexp]], regexpObjects
|
24
|
+
data += add_parameter [[Array]], arrayObjects
|
25
|
+
data += add_parameter [[Hash]], hashObjects
|
26
|
+
end
|
27
|
+
|
28
|
+
def assertKindOfFailData
|
29
|
+
data = add_parameter classes_exclude([Class]), classObjects
|
30
|
+
data += add_parameter classes_exclude([NilClass]), nilObjects
|
31
|
+
data += add_parameter classes_exclude([TrueClass]), trueObjects
|
32
|
+
data += add_parameter classes_exclude([FalseClass]), falseObjects
|
33
|
+
data += add_parameter classes_exclude([Numeric, Integer, Fixnum]), fixnumObjects
|
34
|
+
data += add_parameter classes_exclude([Numeric, Integer, Bignum]), bignumObjects
|
35
|
+
data += add_parameter classes_exclude([Numeric, Float]), floatObjects
|
36
|
+
data += add_parameter classes_exclude([Numeric, Rational]), rationalObjects
|
37
|
+
data += add_parameter classes_exclude([Numeric, Complex]), complexObjects
|
38
|
+
data += add_parameter classes_exclude([Time]), timeObjects
|
39
|
+
data += add_parameter classes_exclude([String]), stringObjects
|
40
|
+
data += add_parameter classes_exclude([Range]), rangeObjects
|
41
|
+
data += add_parameter classes_exclude([Regexp]), regexpObjects
|
42
|
+
data += add_parameter classes_exclude([Array]), arrayObjects
|
43
|
+
data += add_parameter classes_exclude([Hash]), hashObjects
|
44
|
+
end
|
45
|
+
|
46
|
+
def assertKindOfWithMessageData
|
47
|
+
add_parameter assertKindOfData
|
48
|
+
end
|
49
|
+
|
50
|
+
def assertKindOfWithMessageFailData
|
51
|
+
add_parameter assertKindOfFailData
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
module AssertionsTests
|
2
|
+
module ObjectTypes
|
3
|
+
def basicObjects
|
4
|
+
fixnumObjects +
|
5
|
+
bignumObjects +
|
6
|
+
floatObjects +
|
7
|
+
rationalObjects +
|
8
|
+
complexObjects +
|
9
|
+
timeObjects +
|
10
|
+
stringObjects +
|
11
|
+
rangeObjects +
|
12
|
+
regexpObjects +
|
13
|
+
arrayObjects +
|
14
|
+
hashObjects
|
15
|
+
end
|
16
|
+
|
17
|
+
def classes_exclude klasses
|
18
|
+
classes = classObjects
|
19
|
+
klasses.each do |klass|
|
20
|
+
classes -= [[klass]]
|
21
|
+
end
|
22
|
+
classes
|
23
|
+
end
|
24
|
+
|
25
|
+
def classObjects
|
26
|
+
[
|
27
|
+
[ NilClass],
|
28
|
+
[ TrueClass],
|
29
|
+
[FalseClass],
|
30
|
+
[ Numeric],
|
31
|
+
[ Integer],
|
32
|
+
[ Fixnum],
|
33
|
+
[ Bignum],
|
34
|
+
[ Float],
|
35
|
+
[ Rational],
|
36
|
+
[ Complex],
|
37
|
+
[ Time],
|
38
|
+
[ String],
|
39
|
+
[ Range],
|
40
|
+
[ Array],
|
41
|
+
[ Hash],
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def nilObjects
|
46
|
+
[
|
47
|
+
[nil]
|
48
|
+
]
|
49
|
+
end
|
50
|
+
|
51
|
+
def trueObjects
|
52
|
+
[
|
53
|
+
[true]
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def falseObjects
|
58
|
+
[
|
59
|
+
[false]
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def fixnumObjects
|
64
|
+
[
|
65
|
+
[-42],
|
66
|
+
[ -1],
|
67
|
+
[ 0],
|
68
|
+
[ 1],
|
69
|
+
[ 42],
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def bignumObjects
|
74
|
+
[
|
75
|
+
[-42000000000000000000],
|
76
|
+
[ 42000000000000000000],
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def floatObjects
|
81
|
+
[
|
82
|
+
[ -4.2],
|
83
|
+
[-0.042],
|
84
|
+
[ 0.0],
|
85
|
+
[ 0.042],
|
86
|
+
[ 4.2],
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def rationalObjects
|
91
|
+
[
|
92
|
+
[ Rational(1)],
|
93
|
+
[ Rational(2, 3)],
|
94
|
+
[Rational(4, -6)],
|
95
|
+
[ Rational(0.3)],
|
96
|
+
[Rational('0.3')],
|
97
|
+
[Rational('2/3')],
|
98
|
+
]
|
99
|
+
end
|
100
|
+
|
101
|
+
def complexObjects
|
102
|
+
[
|
103
|
+
[ Complex(1)],
|
104
|
+
[ Complex(2, 3)],
|
105
|
+
[Complex.polar(2, 3)],
|
106
|
+
[ Complex(0.3)],
|
107
|
+
[Complex('0.3-0.5i')],
|
108
|
+
[Complex('2/3+3/4i')],
|
109
|
+
[ Complex('1@2')],
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
def timeObjects
|
114
|
+
[
|
115
|
+
[ Time.new(2002)],
|
116
|
+
[ Time.new(2002, 10)],
|
117
|
+
[ Time.new(2002, 10, 31)],
|
118
|
+
[Time.new(2002, 10, 31, 2, 2, 2, "+02:00")],
|
119
|
+
[ Time.at(628232400)],
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def stringObjects
|
124
|
+
[
|
125
|
+
[ ''],
|
126
|
+
[ 'string one'],
|
127
|
+
[ "STRING 2"],
|
128
|
+
[ "String #{42}"],
|
129
|
+
[ 'Two Word string'],
|
130
|
+
["Three\nLINE\nString"],
|
131
|
+
]
|
132
|
+
end
|
133
|
+
|
134
|
+
def rangeObjects
|
135
|
+
[
|
136
|
+
[ (-1..-5)],
|
137
|
+
[ (-5..-1)],
|
138
|
+
[ ('a'..'e')],
|
139
|
+
[('a'...'e')],
|
140
|
+
]
|
141
|
+
end
|
142
|
+
|
143
|
+
def regexpObjects
|
144
|
+
[
|
145
|
+
[ //],
|
146
|
+
[ /Regexp 1/],
|
147
|
+
[ /\AStart Regexp/],
|
148
|
+
[ /END regexp$/],
|
149
|
+
[/^#{'interpolated'} REGEXP$/],
|
150
|
+
]
|
151
|
+
end
|
152
|
+
|
153
|
+
def arrayObjects
|
154
|
+
[
|
155
|
+
[ []],
|
156
|
+
[fixnumObjects.flatten],
|
157
|
+
[ bignumObjects.flatten],
|
158
|
+
[ floatObjects.flatten],
|
159
|
+
[ classObjects.flatten],
|
160
|
+
[ stringObjects.flatten],
|
161
|
+
[ regexpObjects.flatten],
|
162
|
+
]
|
163
|
+
end
|
164
|
+
|
165
|
+
def hashObjects
|
166
|
+
[
|
167
|
+
[ {}],
|
168
|
+
[ {:regex=>/Regexp/}],
|
169
|
+
[ {:string=>'string',:int=>42}],
|
170
|
+
[{:class=>Class,:int=>42,:string=>'string'}],
|
171
|
+
]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'RubyUnit/IncompleteTest'
|
2
|
+
|
3
|
+
module IncompleteTestTests
|
4
|
+
#
|
5
|
+
# Test Case for RubyUnit::IncompleteTest
|
6
|
+
#
|
7
|
+
class TC_IncompleteTest < RubyUnit::TestCase
|
8
|
+
#
|
9
|
+
# Validate that RubyUnit::IncompleteTest is an Exception
|
10
|
+
#
|
11
|
+
def isExceptionTest
|
12
|
+
assertDescendent Exception, RubyUnit::IncompleteTest, 'IncompleteTest MUST be an Exception'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,15 +1,45 @@
|
|
1
1
|
require 'RubyUnit'
|
2
2
|
|
3
|
+
# Data provider for RubyUnit::GemInfo tests
|
4
|
+
require_relative 'data/RubyUnit'
|
5
|
+
|
3
6
|
module RubyUnitTests
|
4
7
|
#
|
5
8
|
# Test Case for the RubyUnit module
|
6
9
|
#
|
7
10
|
class TC_RubyUnit < RubyUnit::TestCase
|
11
|
+
include RubyUnitTestsData
|
12
|
+
|
8
13
|
#
|
9
14
|
# Verify that the VERSION constant is defined in the RubyUnit module
|
10
15
|
#
|
11
16
|
def versionDefinedTest
|
12
17
|
assertConstDefined RubyUnit, 'VERSION', 'Version must be defined in RubyUnit::VERSION'
|
13
18
|
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Test debug mode
|
22
|
+
#
|
23
|
+
def debugModeTest
|
24
|
+
old_mode = RubyUnit.debug
|
25
|
+
RubyUnit.debug = true
|
26
|
+
assertEqual true, RubyUnit.debug, 'Debug mode should be true'
|
27
|
+
RubyUnit.debug = false
|
28
|
+
assertEqual false, RubyUnit.debug, 'Debug mode should be false'
|
29
|
+
RubyUnit.debug = old_mode
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Test that debug mode doesn't accept non-Boolean
|
34
|
+
#
|
35
|
+
def invalidDebugModeTest mode
|
36
|
+
old_mode = RubyUnit.debug
|
37
|
+
assertRaiseExpected ArgumentError, RubyUnit::INVALID_DEBUG_MODE, RubyUnit::INVALID_DEBUG_MODE do
|
38
|
+
RubyUnit.debug = mode
|
39
|
+
end
|
40
|
+
assertEqual old_mode, RubyUnit.debug, 'Invalid debug mode should not change debug mode'
|
41
|
+
ensure
|
42
|
+
RubyUnit.debug = old_mode
|
43
|
+
end
|
14
44
|
end
|
15
45
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'RubyUnit/SkippedTest'
|
2
|
+
|
3
|
+
module SkippedTestTests
|
4
|
+
#
|
5
|
+
# Test Case for RubyUnit::SkippedTest
|
6
|
+
#
|
7
|
+
class TC_SkippedTest < RubyUnit::TestCase
|
8
|
+
#
|
9
|
+
# Validate that RubyUnit::SkippedTest is an Exception
|
10
|
+
#
|
11
|
+
def isExceptionTest
|
12
|
+
assertDescendent Exception, RubyUnit::SkippedTest, 'SkippedTest MUST be an Exception!'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,5 +3,7 @@
|
|
3
3
|
require 'RubyUnit'
|
4
4
|
|
5
5
|
# Test Cases
|
6
|
-
|
7
|
-
|
6
|
+
Dir["#{File.dirname(__FILE__)}/AssertionFailure/TC_*.rb"].each do |test_case|
|
7
|
+
puts "Adding Test Case #{test_case}" if RubyUnit.debug
|
8
|
+
require test_case
|
9
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'RubyUnit'
|
4
|
+
|
5
|
+
module AssertionsTests
|
6
|
+
##
|
7
|
+
# Messages to be used in the tests
|
8
|
+
#
|
9
|
+
MESSAGES = [
|
10
|
+
[ ''],
|
11
|
+
[ 'AssertionsTests Assertion Message'],
|
12
|
+
["#{'iterpolated'} Assertion Message"],
|
13
|
+
]
|
14
|
+
|
15
|
+
class AssertionsTestCase < RubyUnit::TestCase
|
16
|
+
include RubyUnit::AssertionMessage
|
17
|
+
|
18
|
+
##
|
19
|
+
# Keep count of assertions
|
20
|
+
@assertions
|
21
|
+
|
22
|
+
##
|
23
|
+
# Setup tests
|
24
|
+
#
|
25
|
+
def setup
|
26
|
+
@assertions = RubyUnit::TestCase.assertions
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Teardown tests
|
31
|
+
# * All tests on Assertions should add to the assertion count
|
32
|
+
#
|
33
|
+
def teardown
|
34
|
+
assertGreaterThan @@assertions, @assertions, 'Test should make assertions'
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Wrapper to rescue assertions
|
39
|
+
#
|
40
|
+
def rescue_assertion pattern = '', message = nil, data = {}, &block
|
41
|
+
failure = assertRaiseExpected RubyUnit::AssertionFailure, pattern, message do
|
42
|
+
yield
|
43
|
+
end
|
44
|
+
info = failure.info
|
45
|
+
assertMatch /#{message}/, info, 'Assertion failure message mismatch'
|
46
|
+
data.each do |key, value|
|
47
|
+
assertMatch [/#{key}/, /#{value.inspect}/], info, 'Expected failure info not found'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Add parameter on the end of each param list
|
53
|
+
def add_parameter array, params = MESSAGES
|
54
|
+
a = []
|
55
|
+
params.each do |param|
|
56
|
+
a = a + array.collect {|element| element.clone + param}
|
57
|
+
end
|
58
|
+
a
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Test Cases
|
64
|
+
Dir["#{File.dirname(__FILE__)}/Assertions/TC_*.rb"].each do |test_case|
|
65
|
+
puts "Adding Test Case #{test_case}" if RubyUnit.debug
|
66
|
+
require test_case
|
67
|
+
end
|
data/tests/TS_RubyUnit.rb
CHANGED
@@ -3,5 +3,7 @@
|
|
3
3
|
require 'RubyUnit'
|
4
4
|
|
5
5
|
# Test Cases
|
6
|
-
|
7
|
-
|
6
|
+
Dir["#{File.dirname(__FILE__)}/RubyUnit/TC_*.rb"].each do |test_case|
|
7
|
+
puts "Adding Test Case #{test_case}" if RubyUnit.debug
|
8
|
+
require test_case
|
9
|
+
end
|
data/tests/TS_Runner.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'RubyUnit/TestCase'
|
2
|
+
|
3
|
+
# Data provider for RubyUnit::TestCase tests
|
4
|
+
require_relative 'data/TestCase'
|
5
|
+
|
6
|
+
module TestCaseTests
|
7
|
+
#
|
8
|
+
# Test Case for the RubyUnit::TestCase
|
9
|
+
#
|
10
|
+
class TC_TestCase < RubyUnit::TestCase
|
11
|
+
include TestCaseTestsData
|
12
|
+
@setup
|
13
|
+
@teardown
|
14
|
+
|
15
|
+
#
|
16
|
+
# Initialize setup and teardown before each test
|
17
|
+
#
|
18
|
+
def initialize
|
19
|
+
super
|
20
|
+
@setup = false
|
21
|
+
@teardown = false
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
# Track whether class setup has been run
|
26
|
+
@@setup = false
|
27
|
+
# Track whether class teardown has been run
|
28
|
+
@@teardown = false
|
29
|
+
|
30
|
+
#
|
31
|
+
# Setup before class
|
32
|
+
#
|
33
|
+
def setup
|
34
|
+
@@setup = true
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Teardown after class
|
39
|
+
#
|
40
|
+
def teardown
|
41
|
+
@@teardown = true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Setup before test
|
47
|
+
# * self.setup has been run before test begins
|
48
|
+
# * self.teardown has not been run before test begins
|
49
|
+
# * setup is only run once
|
50
|
+
#
|
51
|
+
def setup
|
52
|
+
assert @@setup, 'setup class method MUST be run before tests begin.'
|
53
|
+
assertNot @@teardown, 'teardown class should NOT be run before testing'
|
54
|
+
assertNot @setup, 'setup instance method should only be run once'
|
55
|
+
@setup = true
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Teardown after test
|
60
|
+
#
|
61
|
+
def teardown
|
62
|
+
@teardown = true
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Test that descendents method includes this class
|
67
|
+
#
|
68
|
+
def descendentsTest
|
69
|
+
assertInclude RubyUnit::TestCase.descendents, self.class, 'Should be a descendent of RubyUnit::TestCase'
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# Test that the correct class methods are defined
|
74
|
+
#
|
75
|
+
def classMethodTest method
|
76
|
+
assertClassMethod RubyUnit::TestCase, method, 'RubyUnit::TestCase missing class method'
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Test that the correct instance methods are defined
|
81
|
+
#
|
82
|
+
def instanceMethodTest method
|
83
|
+
assertInstanceMethod RubyUnit::TestCase, method, 'TestCase object missing instance method'
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Test that setup is run before test
|
88
|
+
#
|
89
|
+
def setupBeforeTestTest
|
90
|
+
assert @setup, 'setup instance method MUST be run before test'
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Test that teardown is not run before test
|
95
|
+
#
|
96
|
+
def noTeardownBeforeTestTest
|
97
|
+
assertNot @teardown, 'teardown instance method should NOT be run before test'
|
98
|
+
end
|
99
|
+
|
100
|
+
#
|
101
|
+
# Test that markSkipped raises proper exception
|
102
|
+
#
|
103
|
+
def markSkippedTest
|
104
|
+
message = 'markSkipped should raise RubyUnit::SkippedTest'
|
105
|
+
assertRaiseExpected RubyUnit::SkippedTest, message, message do
|
106
|
+
markSkipped message
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# Test that markIncomplete raises proper exception
|
112
|
+
#
|
113
|
+
def markIncompleteTest
|
114
|
+
message = 'markIncomplete should raise RubyUnit::IncompleteTest'
|
115
|
+
assertRaiseExpected RubyUnit::IncompleteTest, message, message do
|
116
|
+
markIncomplete message
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|