test-unit 2.5.3 → 2.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -1
- data/Rakefile +4 -0
- data/lib/test/unit/assertions.rb +1 -1
- data/lib/test/unit/collector.rb +1 -1
- data/lib/test/unit/data.rb +207 -25
- data/lib/test/unit/testsuite.rb +6 -2
- data/lib/test/unit/ui/console/testrunner.rb +10 -2
- data/lib/test/unit/version.rb +1 -1
- data/test/fixtures/header-label.csv +3 -0
- data/test/fixtures/header-label.tsv +3 -0
- data/test/fixtures/header.csv +3 -0
- data/test/fixtures/header.tsv +3 -0
- data/test/fixtures/no-header.csv +2 -0
- data/test/fixtures/no-header.tsv +2 -0
- data/test/test-assertions.rb +12 -6
- data/test/test-data.rb +101 -11
- data/test/test_testsuite.rb +21 -8
- data/test/testunit-test-util.rb +10 -1
- metadata +105 -93
data/README.textile
CHANGED
data/Rakefile
CHANGED
data/lib/test/unit/assertions.rb
CHANGED
@@ -1838,7 +1838,7 @@ EOT
|
|
1838
1838
|
private
|
1839
1839
|
if Object.const_defined?(:Encoding)
|
1840
1840
|
def encoding_safe_concat(buffer, parameter)
|
1841
|
-
if Encoding.compatible?(buffer
|
1841
|
+
if Encoding.compatible?(buffer, parameter)
|
1842
1842
|
buffer << parameter
|
1843
1843
|
else
|
1844
1844
|
buffer << parameter.dup.force_encoding(buffer.encoding)
|
data/lib/test/unit/collector.rb
CHANGED
data/lib/test/unit/data.rb
CHANGED
@@ -8,11 +8,55 @@ module Test
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ClassMethods
|
11
|
-
#
|
11
|
+
# This method provides Data-Driven-Test functionality.
|
12
|
+
#
|
13
|
+
# Define test data in the test code.
|
14
|
+
#
|
15
|
+
# @overload data(label, data)
|
16
|
+
# @param [String] label specify test case name.
|
17
|
+
# @param data specify test data.
|
18
|
+
#
|
19
|
+
# @example data(label, data)
|
20
|
+
# data("empty string", [true, ""])
|
21
|
+
# data("plain string", [false, "hello"])
|
22
|
+
# def test_empty?(data)
|
23
|
+
# expected, target = data
|
24
|
+
# assert_equal(expected, target.empty?)
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# @overload data(data_set)
|
28
|
+
# @param [Hash] data_set specify test data as a Hash that
|
29
|
+
# key is test label and value is test data.
|
30
|
+
#
|
31
|
+
# @example data(data_set)
|
32
|
+
# data("empty string" => [true, ""],
|
33
|
+
# "plain string" => [false, "hello"])
|
34
|
+
# def test_empty?(data)
|
35
|
+
# expected, target = data
|
36
|
+
# assert_equal(expected, target.empty?)
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# @overload data(&block)
|
40
|
+
# @yieldreturn [Hash] return test data set as a Hash that
|
41
|
+
# key is test label and value is test data.
|
42
|
+
#
|
43
|
+
# @example data(&block)
|
44
|
+
# data do
|
45
|
+
# data_set = {}
|
46
|
+
# data_set["empty string"] = [true, ""]
|
47
|
+
# data_set["plain string"] = [false, "hello"]
|
48
|
+
# data_set
|
49
|
+
# end
|
50
|
+
# def test_empty?(data)
|
51
|
+
# expected, target = data
|
52
|
+
# assert_equal(expected, target.empty?)
|
53
|
+
# end
|
54
|
+
#
|
12
55
|
def data(*arguments, &block)
|
13
56
|
n_arguments = arguments.size
|
14
57
|
case n_arguments
|
15
58
|
when 0
|
59
|
+
raise ArgumentError, "no block is given" unless block_given?
|
16
60
|
data_set = block
|
17
61
|
when 1
|
18
62
|
data_set = arguments[0]
|
@@ -26,52 +70,190 @@ module Test
|
|
26
70
|
attribute(:data, current_data + [data_set])
|
27
71
|
end
|
28
72
|
|
29
|
-
#
|
73
|
+
# This method provides Data-Driven-Test functionality.
|
74
|
+
#
|
75
|
+
# Load test data from the file. This is shorthand to load
|
76
|
+
# test data from file. If you want to load complex file, you
|
77
|
+
# can use {#data} with block.
|
78
|
+
#
|
79
|
+
# @param [String] file_name full path to test data file.
|
80
|
+
# File format is automatically detected from filename extension.
|
81
|
+
# @raise [ArgumentError] if +file_name+ is not supported file format.
|
82
|
+
# @see Loader#load
|
83
|
+
#
|
84
|
+
# @example Load data from CSV file
|
85
|
+
# load_data("/path/to/test-data.csv")
|
86
|
+
# def test_empty?(data)
|
87
|
+
# assert_equal(data["expected"], data["target"].empty?)
|
88
|
+
# end
|
89
|
+
#
|
30
90
|
def load_data(file_name)
|
31
|
-
|
32
|
-
|
33
|
-
loader = CSVDataLoader.new(self)
|
34
|
-
loader.load(file_name)
|
35
|
-
else
|
36
|
-
raise ArgumentError, "unsupported file format: <#{file_name}>"
|
37
|
-
end
|
91
|
+
loader = Loader.new(self)
|
92
|
+
loader.load(file_name)
|
38
93
|
end
|
39
94
|
|
40
|
-
class
|
95
|
+
class Loader
|
96
|
+
# @api private
|
41
97
|
def initialize(test_case)
|
42
98
|
@test_case = test_case
|
43
99
|
end
|
44
100
|
|
101
|
+
# Load data from file.
|
102
|
+
#
|
103
|
+
# @param [String] file_name full path to test data file.
|
104
|
+
# File format is automatically detected from filename extension.
|
105
|
+
# @raise [ArgumentError] if +file_name+ is not supported file format.
|
106
|
+
# @see #load_csv
|
107
|
+
# @see #load_tsv
|
108
|
+
# @api private
|
45
109
|
def load(file_name)
|
110
|
+
case File.extname(file_name).downcase
|
111
|
+
when ".csv"
|
112
|
+
load_csv(file_name)
|
113
|
+
when ".tsv"
|
114
|
+
load_tsv(file_name)
|
115
|
+
else
|
116
|
+
raise ArgumentError, "unsupported file format: <#{file_name}>"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Load data from CSV file.
|
121
|
+
#
|
122
|
+
# There are 2 types of CSV file as following examples.
|
123
|
+
# First, there is a header on first row and it's first column is "label".
|
124
|
+
# Another, there is no header in the file.
|
125
|
+
#
|
126
|
+
# @example Load data from CSV file with header
|
127
|
+
# # test-data.csv:
|
128
|
+
# # label,expected,target
|
129
|
+
# # empty string,true,""
|
130
|
+
# # plain string,false,hello
|
131
|
+
# #
|
132
|
+
# load_data("/path/to/test-data.csv")
|
133
|
+
# def test_empty?(data)
|
134
|
+
# assert_equal(data["expected"], data["target"].empty?)
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# @example Load data from CSV file without header
|
138
|
+
# # test-data-without-header.csv:
|
139
|
+
# # empty string,true,""
|
140
|
+
# # plain string,false,hello
|
141
|
+
# #
|
142
|
+
# load_data("/path/to/test-data-without-header.csv")
|
143
|
+
# def test_empty?(data)
|
144
|
+
# expected, target = data
|
145
|
+
# assert_equal(expected, target.empty?)
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
# @api private
|
149
|
+
def load_csv(file_name)
|
46
150
|
require 'csv'
|
151
|
+
first_row = true
|
47
152
|
header = nil
|
48
153
|
CSV.foreach(file_name) do |row|
|
49
|
-
if
|
50
|
-
|
51
|
-
|
154
|
+
if first_row
|
155
|
+
first_row = false
|
156
|
+
if row.first == "label"
|
157
|
+
header = row[1..-1]
|
158
|
+
next
|
159
|
+
end
|
52
160
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
161
|
+
|
162
|
+
set_test_data(header, row)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Load data from TSV file.
|
167
|
+
#
|
168
|
+
# There are 2 types of TSV file as following examples.
|
169
|
+
# First, there is a header on first row and it's first column is "label".
|
170
|
+
# Another, there is no header in the file.
|
171
|
+
#
|
172
|
+
# @example Load data from TSV file with header
|
173
|
+
# # test-data.tsv:
|
174
|
+
# # label expected target
|
175
|
+
# # empty string true ""
|
176
|
+
# # plain string false hello
|
177
|
+
# #
|
178
|
+
# load_data("/path/to/test-data.tsv")
|
179
|
+
# def test_empty?(data)
|
180
|
+
# assert_equal(data["expected"], data["target"].empty?)
|
181
|
+
# end
|
182
|
+
#
|
183
|
+
# @example Load data from TSV file without header
|
184
|
+
# # test-data-without-header.tsv:
|
185
|
+
# # empty string true ""
|
186
|
+
# # plain string false hello
|
187
|
+
# #
|
188
|
+
# load_data("/path/to/test-data-without-header.tsv")
|
189
|
+
# def test_empty?(data)
|
190
|
+
# expected, target = data
|
191
|
+
# assert_equal(expected, target.empty?)
|
192
|
+
# end
|
193
|
+
#
|
194
|
+
# @api private
|
195
|
+
def load_tsv(file_name)
|
196
|
+
require "csv"
|
197
|
+
if CSV.respond_to?(:dump)
|
198
|
+
first_row = true
|
199
|
+
header = nil
|
200
|
+
CSV.foreach(file_name, :col_sep => "\t") do |row|
|
201
|
+
if first_row
|
202
|
+
first_row = false
|
203
|
+
if row.first == "label"
|
204
|
+
header = row[1..-1]
|
205
|
+
next
|
206
|
+
end
|
60
207
|
end
|
208
|
+
|
209
|
+
set_test_data(header, row)
|
210
|
+
end
|
211
|
+
else
|
212
|
+
# for old CSV library
|
213
|
+
first_row = true
|
214
|
+
header = nil
|
215
|
+
CSV.open(file_name, "r", "\t") do |row|
|
216
|
+
if first_row
|
217
|
+
first_row = false
|
218
|
+
if row.first == "label"
|
219
|
+
header = row[1..-1]
|
220
|
+
next
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
set_test_data(header, row)
|
61
225
|
end
|
62
|
-
@test_case.data(label, data)
|
63
226
|
end
|
64
227
|
end
|
65
228
|
|
66
229
|
private
|
67
230
|
def normalize_value(value)
|
68
|
-
|
69
|
-
|
231
|
+
return true if value == "true"
|
232
|
+
return false if value == "false"
|
70
233
|
begin
|
71
|
-
|
234
|
+
Integer(value)
|
72
235
|
rescue ArgumentError
|
73
|
-
|
236
|
+
begin
|
237
|
+
Float(value)
|
238
|
+
rescue ArgumentError
|
239
|
+
value
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def set_test_data(header, row)
|
245
|
+
label = row.shift
|
246
|
+
if header
|
247
|
+
data = {}
|
248
|
+
header.each_with_index do |key, i|
|
249
|
+
data[key] = normalize_value(row[i])
|
250
|
+
end
|
251
|
+
else
|
252
|
+
data = row.collect do |cell|
|
253
|
+
normalize_value(cell)
|
254
|
+
end
|
74
255
|
end
|
256
|
+
@test_case.data(label, data)
|
75
257
|
end
|
76
258
|
end
|
77
259
|
end
|
data/lib/test/unit/testsuite.rb
CHANGED
@@ -70,6 +70,10 @@ module Test
|
|
70
70
|
@tests.delete(test)
|
71
71
|
end
|
72
72
|
|
73
|
+
def delete_tests(tests)
|
74
|
+
@tests -= tests
|
75
|
+
end
|
76
|
+
|
73
77
|
# Retuns the rolled up number of tests in this suite;
|
74
78
|
# i.e. if the suite contains other suites, it counts the
|
75
79
|
# tests within those suites, not the suites themselves.
|
@@ -78,7 +82,7 @@ module Test
|
|
78
82
|
@tests.each { |test| total_size += test.size }
|
79
83
|
total_size
|
80
84
|
end
|
81
|
-
|
85
|
+
|
82
86
|
def empty?
|
83
87
|
size.zero?
|
84
88
|
end
|
@@ -88,7 +92,7 @@ module Test
|
|
88
92
|
def to_s
|
89
93
|
@name
|
90
94
|
end
|
91
|
-
|
95
|
+
|
92
96
|
# It's handy to be able to compare TestSuite instances.
|
93
97
|
def ==(other)
|
94
98
|
return false unless(other.kind_of?(self.class))
|
@@ -343,6 +343,15 @@ module Test
|
|
343
343
|
output(": (%f)" % (Time.now - @test_start), nil, VERBOSE)
|
344
344
|
end
|
345
345
|
|
346
|
+
def suite_name(prefix, suite)
|
347
|
+
name = suite.name
|
348
|
+
if name.nil?
|
349
|
+
"(anonymous)"
|
350
|
+
else
|
351
|
+
name.sub(/\A#{Regexp.escape(prefix)}/, "")
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
346
355
|
def test_suite_started(suite)
|
347
356
|
last_test_suite = @test_suites.last
|
348
357
|
@test_suites << suite
|
@@ -358,8 +367,7 @@ module Test
|
|
358
367
|
_color = color("case")
|
359
368
|
end
|
360
369
|
prefix = "#{last_test_suite.name}::"
|
361
|
-
suite_name
|
362
|
-
output_single(suite_name, _color, VERBOSE)
|
370
|
+
output_single(suite_name(prefix, suite), _color, VERBOSE)
|
363
371
|
output(": ", nil, VERBOSE)
|
364
372
|
@indent += 2
|
365
373
|
end
|
data/lib/test/unit/version.rb
CHANGED
data/test/test-assertions.rb
CHANGED
@@ -10,6 +10,8 @@ require 'test/unit'
|
|
10
10
|
module Test
|
11
11
|
module Unit
|
12
12
|
module AssertionCheckable
|
13
|
+
include TestUnitTestUtil
|
14
|
+
|
13
15
|
private
|
14
16
|
def check(value, message="")
|
15
17
|
add_assertion
|
@@ -100,12 +102,16 @@ module Test
|
|
100
102
|
end
|
101
103
|
|
102
104
|
def inspect_tag(tag)
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
if jruby?
|
106
|
+
"`#{tag}'".inspect
|
107
|
+
else
|
108
|
+
begin
|
109
|
+
throw tag
|
110
|
+
rescue NameError
|
111
|
+
tag.to_s.inspect
|
112
|
+
rescue ArgumentError
|
113
|
+
tag.inspect
|
114
|
+
end
|
109
115
|
end
|
110
116
|
end
|
111
117
|
|
data/test/test-data.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "testunit-test-util"
|
2
|
+
|
1
3
|
class TestData < Test::Unit::TestCase
|
2
4
|
class Calc
|
3
5
|
def initialize
|
@@ -66,8 +68,8 @@ class TestData < Test::Unit::TestCase
|
|
66
68
|
end
|
67
69
|
|
68
70
|
class TestLoadDataSet < TestCalc
|
69
|
-
|
70
|
-
load_data("
|
71
|
+
extend TestUnitTestUtil
|
72
|
+
load_data(fixture_file_path("plus.csv"))
|
71
73
|
def test_plus(data)
|
72
74
|
assert_equal(data["expected"],
|
73
75
|
@calc.plus(data["augend"], data["addend"]))
|
@@ -83,6 +85,12 @@ class TestData < Test::Unit::TestCase
|
|
83
85
|
TestCalc.testing = false
|
84
86
|
end
|
85
87
|
|
88
|
+
def test_data_no_arguments_without_block
|
89
|
+
assert_raise(ArgumentError) do
|
90
|
+
self.class.data
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
86
94
|
data("data set",
|
87
95
|
{
|
88
96
|
:test_case => TestCalc::TestDataSet,
|
@@ -146,10 +154,10 @@ class TestData < Test::Unit::TestCase
|
|
146
154
|
assert_not_nil(data[:data_set])
|
147
155
|
end
|
148
156
|
|
149
|
-
data("data set"
|
150
|
-
"n-data"
|
157
|
+
data("data set" => TestCalc::TestDataSet,
|
158
|
+
"n-data" => TestCalc::TestNData,
|
151
159
|
"dynamic-data-set" => TestCalc::TestDynamicDataSet,
|
152
|
-
"load-data-set"
|
160
|
+
"load-data-set" => TestCalc::TestLoadDataSet)
|
153
161
|
def test_suite(test_case)
|
154
162
|
suite = test_case.suite
|
155
163
|
assert_equal(["test_plus[positive negative](#{test_case.name})",
|
@@ -157,20 +165,20 @@ class TestData < Test::Unit::TestCase
|
|
157
165
|
suite.tests.collect {|test| test.name}.sort)
|
158
166
|
end
|
159
167
|
|
160
|
-
data("data set"
|
161
|
-
"n-data"
|
168
|
+
data("data set" => TestCalc::TestDataSet,
|
169
|
+
"n-data" => TestCalc::TestNData,
|
162
170
|
"dynamic-data-set" => TestCalc::TestDynamicDataSet,
|
163
|
-
"load-data-set"
|
171
|
+
"load-data-set" => TestCalc::TestLoadDataSet)
|
164
172
|
def test_run(test_case)
|
165
173
|
result = _run_test(test_case)
|
166
174
|
assert_equal("2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, " \
|
167
175
|
"0 omissions, 0 notifications", result.to_s)
|
168
176
|
end
|
169
177
|
|
170
|
-
data("data set"
|
171
|
-
"n-data"
|
178
|
+
data("data set" => TestCalc::TestDataSet,
|
179
|
+
"n-data" => TestCalc::TestNData,
|
172
180
|
"dynamic-data-set" => TestCalc::TestDynamicDataSet,
|
173
|
-
"load-data-set"
|
181
|
+
"load-data-set" => TestCalc::TestLoadDataSet)
|
174
182
|
def test_equal(test_case)
|
175
183
|
suite = test_case.suite
|
176
184
|
positive_positive_test = suite.tests.find do |test|
|
@@ -181,6 +189,16 @@ class TestData < Test::Unit::TestCase
|
|
181
189
|
suite.tests.collect {|test| test.name}.sort)
|
182
190
|
end
|
183
191
|
|
192
|
+
data("true" => {:expected => true, :target => "true"},
|
193
|
+
"false" => {:expected => false, :target => "false"},
|
194
|
+
"integer" => {:expected => 1, :target => "1"},
|
195
|
+
"float" => {:expected => 1.5, :target => "1.5"},
|
196
|
+
"string" => {:expected => "hello", :target => "hello"})
|
197
|
+
def test_normalize_value(data)
|
198
|
+
loader = Test::Unit::Data::ClassMethods::Loader.new(self)
|
199
|
+
assert_equal(data[:expected], loader.__send__(:normalize_value, data[:target]))
|
200
|
+
end
|
201
|
+
|
184
202
|
def _run_test(test_case)
|
185
203
|
result = Test::Unit::TestResult.new
|
186
204
|
test = test_case.suite
|
@@ -188,4 +206,76 @@ class TestData < Test::Unit::TestCase
|
|
188
206
|
test.run(result) {}
|
189
207
|
result
|
190
208
|
end
|
209
|
+
|
210
|
+
class TestLoadData < Test::Unit::TestCase
|
211
|
+
include TestUnitTestUtil
|
212
|
+
def test_invalid_csv_file_name
|
213
|
+
garbage = "X"
|
214
|
+
file_name = "data.csv#{garbage}"
|
215
|
+
assert_raise(ArgumentError, "unsupported file format: <#{file_name}>") do
|
216
|
+
self.class.load_data(file_name)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
class TestFileFormat < self
|
221
|
+
def setup
|
222
|
+
self.class.current_attribute(:data).clear
|
223
|
+
end
|
224
|
+
|
225
|
+
class TestHeader < self
|
226
|
+
data("csv" => "header.csv",
|
227
|
+
"tsv" => "header.tsv")
|
228
|
+
def test_normal(file_name)
|
229
|
+
self.class.load_data(fixture_file_path(file_name))
|
230
|
+
assert_equal([
|
231
|
+
{
|
232
|
+
"empty string" => {
|
233
|
+
"expected" => true,
|
234
|
+
"target" => ""
|
235
|
+
}
|
236
|
+
},
|
237
|
+
{
|
238
|
+
"plain string" => {
|
239
|
+
"expected" => false,
|
240
|
+
"target" => "hello"
|
241
|
+
}
|
242
|
+
}
|
243
|
+
],
|
244
|
+
self.class.current_attribute(:data)[:value])
|
245
|
+
end
|
246
|
+
|
247
|
+
data("csv" => "header-label.csv",
|
248
|
+
"tsv" => "header-label.tsv")
|
249
|
+
def test_label(file_name)
|
250
|
+
self.class.load_data(fixture_file_path(file_name))
|
251
|
+
assert_equal([
|
252
|
+
{
|
253
|
+
"upper case" => {
|
254
|
+
"expected" => "HELLO",
|
255
|
+
"label" => "HELLO"
|
256
|
+
}
|
257
|
+
},
|
258
|
+
{
|
259
|
+
"lower case" => {
|
260
|
+
"expected" => "Hello",
|
261
|
+
"label" => "hello"
|
262
|
+
}
|
263
|
+
}
|
264
|
+
],
|
265
|
+
self.class.current_attribute(:data)[:value])
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
data("csv" => "no-header.csv",
|
270
|
+
"tsv" => "no-header.tsv")
|
271
|
+
def test_without_header(file_name)
|
272
|
+
self.class.load_data(fixture_file_path(file_name))
|
273
|
+
assert_equal([
|
274
|
+
{"empty string" => [true, ""]},
|
275
|
+
{"plain string" => [false, "hello"]}
|
276
|
+
],
|
277
|
+
self.class.current_attribute(:data)[:value])
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
191
281
|
end
|
data/test/test_testsuite.rb
CHANGED
@@ -43,6 +43,19 @@ module Test
|
|
43
43
|
assert_equal(TestSuite.new << t2, s)
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_delete_tests
|
47
|
+
suite = TestSuite.new
|
48
|
+
test1 = self.class.new("test_delete_1")
|
49
|
+
suite << test1
|
50
|
+
test2 = self.class.new("test_delete_2")
|
51
|
+
suite << test2
|
52
|
+
test3 = self.class.new("test_add")
|
53
|
+
suite << test3
|
54
|
+
suite.delete_tests([test1, test2])
|
55
|
+
assert_equal(1, suite.size)
|
56
|
+
assert_equal(TestSuite.new << test3, suite)
|
57
|
+
end
|
58
|
+
|
46
59
|
def test_size
|
47
60
|
suite = TestSuite.new
|
48
61
|
suite2 = TestSuite.new
|
@@ -51,7 +64,7 @@ module Test
|
|
51
64
|
suite << self.class.new("test_size")
|
52
65
|
assert_equal(2, suite.size, "The count should be correct")
|
53
66
|
end
|
54
|
-
|
67
|
+
|
55
68
|
def test_run
|
56
69
|
progress = []
|
57
70
|
suite = @testcase1.suite
|
@@ -89,34 +102,34 @@ module Test
|
|
89
102
|
assert_equal(28, progress.size,
|
90
103
|
"Should have had the correct number of progress calls")
|
91
104
|
end
|
92
|
-
|
105
|
+
|
93
106
|
def test_empty?
|
94
107
|
assert(TestSuite.new.empty?, "A new test suite should be empty?")
|
95
108
|
assert(!@testcase2.suite.empty?, "A test suite with tests should not be empty")
|
96
109
|
end
|
97
|
-
|
110
|
+
|
98
111
|
def test_equality
|
99
112
|
suite1 = TestSuite.new
|
100
113
|
suite2 = TestSuite.new
|
101
114
|
assert_equal(suite1, suite2)
|
102
115
|
assert_equal(suite2, suite1)
|
103
|
-
|
116
|
+
|
104
117
|
suite1 = TestSuite.new('name')
|
105
118
|
assert_not_equal(suite1, suite2)
|
106
119
|
assert_not_equal(suite2, suite1)
|
107
|
-
|
120
|
+
|
108
121
|
suite2 = TestSuite.new('name')
|
109
122
|
assert_equal(suite1, suite2)
|
110
123
|
assert_equal(suite2, suite1)
|
111
|
-
|
124
|
+
|
112
125
|
suite1 << 'test'
|
113
126
|
assert_not_equal(suite1, suite2)
|
114
127
|
assert_not_equal(suite2, suite1)
|
115
|
-
|
128
|
+
|
116
129
|
suite2 << 'test'
|
117
130
|
assert_equal(suite1, suite2)
|
118
131
|
assert_equal(suite2, suite1)
|
119
|
-
|
132
|
+
|
120
133
|
suite2 = Object.new
|
121
134
|
class << suite2
|
122
135
|
def name
|
data/test/testunit-test-util.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
module TestUnitTestUtil
|
2
2
|
private
|
3
|
+
def jruby?
|
4
|
+
RUBY_PLATFORM == "java"
|
5
|
+
end
|
6
|
+
|
3
7
|
def jruby_only_test
|
4
|
-
if
|
8
|
+
if jruby?
|
5
9
|
require "java"
|
6
10
|
else
|
7
11
|
omit("test for JRuby")
|
@@ -19,4 +23,9 @@ module TestUnitTestUtil
|
|
19
23
|
test.run(result) {}
|
20
24
|
result
|
21
25
|
end
|
26
|
+
|
27
|
+
def fixture_file_path(file_name)
|
28
|
+
base_dir = File.dirname(__FILE__)
|
29
|
+
File.join(base_dir, "fixtures", file_name)
|
30
|
+
end
|
22
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-01-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -96,91 +96,97 @@ files:
|
|
96
96
|
- COPYING
|
97
97
|
- GPL
|
98
98
|
- PSFL
|
99
|
-
- lib/test
|
100
|
-
- lib/test/unit
|
101
|
-
- lib/test/unit/
|
102
|
-
- lib/test/unit/data.rb
|
103
|
-
- lib/test/unit/testsuitecreator.rb
|
99
|
+
- lib/test-unit.rb
|
100
|
+
- lib/test/unit.rb
|
101
|
+
- lib/test/unit/priority.rb
|
104
102
|
- lib/test/unit/color.rb
|
105
|
-
- lib/test/unit/
|
106
|
-
- lib/test/unit/
|
107
|
-
- lib/test/unit/testresult.rb
|
108
|
-
- lib/test/unit/util/observable.rb
|
109
|
-
- lib/test/unit/util/method-owner-finder.rb
|
110
|
-
- lib/test/unit/util/procwrapper.rb
|
111
|
-
- lib/test/unit/util/output.rb
|
112
|
-
- lib/test/unit/util/backtracefilter.rb
|
113
|
-
- lib/test/unit/ui/xml/testrunner.rb
|
114
|
-
- lib/test/unit/ui/testrunnermediator.rb
|
115
|
-
- lib/test/unit/ui/testrunner.rb
|
103
|
+
- lib/test/unit/fixture.rb
|
104
|
+
- lib/test/unit/collector.rb
|
116
105
|
- lib/test/unit/ui/testrunnerutilities.rb
|
117
|
-
- lib/test/unit/ui/
|
106
|
+
- lib/test/unit/ui/testrunner.rb
|
118
107
|
- lib/test/unit/ui/console/testrunner.rb
|
119
108
|
- lib/test/unit/ui/console/outputlevel.rb
|
120
|
-
- lib/test/unit/
|
121
|
-
- lib/test/unit/
|
122
|
-
- lib/test/unit/
|
109
|
+
- lib/test/unit/ui/emacs/testrunner.rb
|
110
|
+
- lib/test/unit/ui/testrunnermediator.rb
|
111
|
+
- lib/test/unit/ui/xml/testrunner.rb
|
112
|
+
- lib/test/unit/data.rb
|
113
|
+
- lib/test/unit/testsuite.rb
|
114
|
+
- lib/test/unit/collector/objectspace.rb
|
115
|
+
- lib/test/unit/collector/descendant.rb
|
116
|
+
- lib/test/unit/collector/dir.rb
|
117
|
+
- lib/test/unit/collector/xml.rb
|
118
|
+
- lib/test/unit/collector/load.rb
|
119
|
+
- lib/test/unit/fault-location-detector.rb
|
123
120
|
- lib/test/unit/color-scheme.rb
|
124
|
-
- lib/test/unit/
|
121
|
+
- lib/test/unit/error.rb
|
122
|
+
- lib/test/unit/failure.rb
|
123
|
+
- lib/test/unit/testresult.rb
|
124
|
+
- lib/test/unit/attribute.rb
|
125
|
+
- lib/test/unit/exceptionhandler.rb
|
126
|
+
- lib/test/unit/autorunner.rb
|
127
|
+
- lib/test/unit/notification.rb
|
128
|
+
- lib/test/unit/testsuitecreator.rb
|
125
129
|
- lib/test/unit/diff.rb
|
126
|
-
- lib/test/unit/pending.rb
|
127
130
|
- lib/test/unit/omission.rb
|
128
|
-
- lib/test/unit/
|
129
|
-
- lib/test/unit/
|
130
|
-
- lib/test/unit/
|
131
|
-
- lib/test/unit/
|
131
|
+
- lib/test/unit/version.rb
|
132
|
+
- lib/test/unit/assertionfailederror.rb
|
133
|
+
- lib/test/unit/util/method-owner-finder.rb
|
134
|
+
- lib/test/unit/util/backtracefilter.rb
|
135
|
+
- lib/test/unit/util/output.rb
|
136
|
+
- lib/test/unit/util/procwrapper.rb
|
137
|
+
- lib/test/unit/util/observable.rb
|
132
138
|
- lib/test/unit/runner/console.rb
|
139
|
+
- lib/test/unit/runner/xml.rb
|
133
140
|
- lib/test/unit/runner/emacs.rb
|
134
|
-
- lib/test/unit/notification.rb
|
135
|
-
- lib/test/unit/fixture.rb
|
136
|
-
- lib/test/unit/code-snippet-fetcher.rb
|
137
141
|
- lib/test/unit/testcase.rb
|
138
|
-
- lib/test/unit/
|
139
|
-
- lib/test/unit/
|
140
|
-
- lib/test/unit/
|
141
|
-
- lib/test/unit/
|
142
|
-
- lib/test/unit/collector/descendant.rb
|
143
|
-
- lib/test/unit/error.rb
|
144
|
-
- lib/test/unit.rb
|
145
|
-
- lib/test-unit.rb
|
142
|
+
- lib/test/unit/assertions.rb
|
143
|
+
- lib/test/unit/attribute-matcher.rb
|
144
|
+
- lib/test/unit/pending.rb
|
145
|
+
- lib/test/unit/code-snippet-fetcher.rb
|
146
146
|
- sample/subtracter.rb
|
147
|
+
- sample/test_subtracter.rb
|
147
148
|
- sample/adder.rb
|
148
149
|
- sample/test_user.rb
|
149
|
-
- sample/test_subtracter.rb
|
150
150
|
- sample/test_adder.rb
|
151
|
-
- test/
|
151
|
+
- test/test-diff.rb
|
152
152
|
- test/test-testcase.rb
|
153
|
-
- test/test-
|
154
|
-
- test/testunit-test-util.rb
|
153
|
+
- test/test-attribute-matcher.rb
|
155
154
|
- test/test-code-snippet.rb
|
156
|
-
- test/test_failure.rb
|
157
|
-
- test/test-assertions.rb
|
158
|
-
- test/test-attribute.rb
|
159
|
-
- test/test-priority.rb
|
160
|
-
- test/test-fixture.rb
|
161
|
-
- test/test-color-scheme.rb
|
162
|
-
- test/util/test_backtracefilter.rb
|
163
|
-
- test/util/test-output.rb
|
164
|
-
- test/util/test-method-owner-finder.rb
|
165
|
-
- test/util/test_procwrapper.rb
|
166
|
-
- test/util/test_observable.rb
|
167
|
-
- test/test-diff.rb
|
168
155
|
- test/ui/test_testrunmediator.rb
|
169
|
-
- test/fixtures/plus.csv
|
170
|
-
- test/test-fault-location-detector.rb
|
171
156
|
- test/test-notification.rb
|
172
|
-
- test/
|
157
|
+
- test/test-color-scheme.rb
|
173
158
|
- test/test_testresult.rb
|
174
|
-
- test/test-
|
175
|
-
- test/test-color.rb
|
176
|
-
- test/test_error.rb
|
177
|
-
- test/test-data.rb
|
178
|
-
- test/test-pending.rb
|
179
|
-
- test/test-attribute-matcher.rb
|
180
|
-
- test/collector/test_objectspace.rb
|
159
|
+
- test/test-attribute.rb
|
181
160
|
- test/collector/test-load.rb
|
182
161
|
- test/collector/test-descendant.rb
|
183
162
|
- test/collector/test_dir.rb
|
163
|
+
- test/collector/test_objectspace.rb
|
164
|
+
- test/run-test.rb
|
165
|
+
- test/test-emacs-runner.rb
|
166
|
+
- test/test-omission.rb
|
167
|
+
- test/test-priority.rb
|
168
|
+
- test/test-fixture.rb
|
169
|
+
- test/test-pending.rb
|
170
|
+
- test/test_error.rb
|
171
|
+
- test/test-color.rb
|
172
|
+
- test/test-data.rb
|
173
|
+
- test/test-assertions.rb
|
174
|
+
- test/test_failure.rb
|
175
|
+
- test/test_testsuite.rb
|
176
|
+
- test/test-fault-location-detector.rb
|
177
|
+
- test/fixtures/header-label.tsv
|
178
|
+
- test/fixtures/plus.csv
|
179
|
+
- test/fixtures/no-header.tsv
|
180
|
+
- test/fixtures/header-label.csv
|
181
|
+
- test/fixtures/no-header.csv
|
182
|
+
- test/fixtures/header.tsv
|
183
|
+
- test/fixtures/header.csv
|
184
|
+
- test/util/test_procwrapper.rb
|
185
|
+
- test/util/test-output.rb
|
186
|
+
- test/util/test_observable.rb
|
187
|
+
- test/util/test-method-owner-finder.rb
|
188
|
+
- test/util/test_backtracefilter.rb
|
189
|
+
- test/testunit-test-util.rb
|
184
190
|
homepage: http://test-unit.rubyforge.org/
|
185
191
|
licenses:
|
186
192
|
- Ruby's and PSFL (lib/test/unit/diff.rb)
|
@@ -196,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
202
|
version: '0'
|
197
203
|
segments:
|
198
204
|
- 0
|
199
|
-
hash: -
|
205
|
+
hash: -757273133856751205
|
200
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
207
|
none: false
|
202
208
|
requirements:
|
@@ -205,45 +211,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
211
|
version: '0'
|
206
212
|
segments:
|
207
213
|
- 0
|
208
|
-
hash: -
|
214
|
+
hash: -757273133856751205
|
209
215
|
requirements: []
|
210
216
|
rubyforge_project: test-unit
|
211
|
-
rubygems_version: 1.8.
|
217
|
+
rubygems_version: 1.8.24
|
212
218
|
signing_key:
|
213
219
|
specification_version: 3
|
214
220
|
summary: test-unit - Improved version of Test::Unit bundled in Ruby 1.8.x.
|
215
221
|
test_files:
|
216
|
-
- test/
|
222
|
+
- test/test-diff.rb
|
217
223
|
- test/test-testcase.rb
|
218
|
-
- test/test-
|
219
|
-
- test/testunit-test-util.rb
|
224
|
+
- test/test-attribute-matcher.rb
|
220
225
|
- test/test-code-snippet.rb
|
221
|
-
- test/test_failure.rb
|
222
|
-
- test/test-assertions.rb
|
223
|
-
- test/test-attribute.rb
|
224
|
-
- test/test-priority.rb
|
225
|
-
- test/test-fixture.rb
|
226
|
-
- test/test-color-scheme.rb
|
227
|
-
- test/util/test_backtracefilter.rb
|
228
|
-
- test/util/test-output.rb
|
229
|
-
- test/util/test-method-owner-finder.rb
|
230
|
-
- test/util/test_procwrapper.rb
|
231
|
-
- test/util/test_observable.rb
|
232
|
-
- test/test-diff.rb
|
233
226
|
- test/ui/test_testrunmediator.rb
|
234
|
-
- test/fixtures/plus.csv
|
235
|
-
- test/test-fault-location-detector.rb
|
236
227
|
- test/test-notification.rb
|
237
|
-
- test/
|
228
|
+
- test/test-color-scheme.rb
|
238
229
|
- test/test_testresult.rb
|
239
|
-
- test/test-
|
240
|
-
- test/test-color.rb
|
241
|
-
- test/test_error.rb
|
242
|
-
- test/test-data.rb
|
243
|
-
- test/test-pending.rb
|
244
|
-
- test/test-attribute-matcher.rb
|
245
|
-
- test/collector/test_objectspace.rb
|
230
|
+
- test/test-attribute.rb
|
246
231
|
- test/collector/test-load.rb
|
247
232
|
- test/collector/test-descendant.rb
|
248
233
|
- test/collector/test_dir.rb
|
234
|
+
- test/collector/test_objectspace.rb
|
235
|
+
- test/run-test.rb
|
236
|
+
- test/test-emacs-runner.rb
|
237
|
+
- test/test-omission.rb
|
238
|
+
- test/test-priority.rb
|
239
|
+
- test/test-fixture.rb
|
240
|
+
- test/test-pending.rb
|
241
|
+
- test/test_error.rb
|
242
|
+
- test/test-color.rb
|
243
|
+
- test/test-data.rb
|
244
|
+
- test/test-assertions.rb
|
245
|
+
- test/test_failure.rb
|
246
|
+
- test/test_testsuite.rb
|
247
|
+
- test/test-fault-location-detector.rb
|
248
|
+
- test/fixtures/header-label.tsv
|
249
|
+
- test/fixtures/plus.csv
|
250
|
+
- test/fixtures/no-header.tsv
|
251
|
+
- test/fixtures/header-label.csv
|
252
|
+
- test/fixtures/no-header.csv
|
253
|
+
- test/fixtures/header.tsv
|
254
|
+
- test/fixtures/header.csv
|
255
|
+
- test/util/test_procwrapper.rb
|
256
|
+
- test/util/test-output.rb
|
257
|
+
- test/util/test_observable.rb
|
258
|
+
- test/util/test-method-owner-finder.rb
|
259
|
+
- test/util/test_backtracefilter.rb
|
260
|
+
- test/testunit-test-util.rb
|
249
261
|
has_rdoc:
|