test-unit 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/text/news.md +14 -0
- data/lib/test/unit/collector.rb +6 -3
- data/lib/test/unit/version.rb +1 -1
- data/test/collector/test-descendant.rb +133 -88
- data/test/test-test-case.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82214fb59acb16827aacf60b960cefc080128e3d
|
4
|
+
data.tar.gz: 2639d42836d7ca114f9acb65e1e6c67136672acc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 814c6f16fe4e256ad788617cb627441b93ce32c20a3b8972e5e4e799534a8c3350ff77ecdef0bc13ab6fcb5b532b7efec814717f2cfee6fbbabdfd04829f5b4c
|
7
|
+
data.tar.gz: a6301d7b7e109157505e354dd3c43393921f51b10bbddd5f44e26f1e2689b8c7be9059da74d61be8bfc73fc626ae3f9d601292ccbb1ce9d80f14bb0f21fe5327
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.0.5 - 2014-11-08 {#version-3-0-5}
|
4
|
+
|
5
|
+
It's a minor update release.
|
6
|
+
|
7
|
+
### Fixes
|
8
|
+
|
9
|
+
* Fixed a bug that startup/shutdown of parent test case isn't called
|
10
|
+
when the test case includes one or more modules.
|
11
|
+
[GitHub#83][Reported by Chadderton Odwazny]
|
12
|
+
|
13
|
+
### Thanks
|
14
|
+
|
15
|
+
* Chadderton Odwazny
|
16
|
+
|
3
17
|
## 3.0.4 - 2014-11-01 {#version-3-0-4}
|
4
18
|
|
5
19
|
It's a minor update release.
|
data/lib/test/unit/collector.rb
CHANGED
@@ -24,10 +24,13 @@ module Test
|
|
24
24
|
|
25
25
|
def add_test_cases(suite, test_cases)
|
26
26
|
children_map = {}
|
27
|
-
test_cases.each do |
|
28
|
-
|
27
|
+
test_cases.each do |test_case|
|
28
|
+
ancestor_classes = test_case.ancestors.find_all do |ancestor|
|
29
|
+
ancestor.is_a?(Class)
|
30
|
+
end
|
31
|
+
parent = ancestor_classes[1]
|
29
32
|
children_map[parent] ||= []
|
30
|
-
children_map[parent] <<
|
33
|
+
children_map[parent] << test_case
|
31
34
|
end
|
32
35
|
|
33
36
|
root_test_cases = children_map.keys - test_cases
|
data/lib/test/unit/version.rb
CHANGED
@@ -5,129 +5,174 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
|
7
7
|
Test::Unit::TestCase::DESCENDANTS.clear
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def assert_collect(expected, *collect_args)
|
16
|
+
collector = Test::Unit::Collector::Descendant.new
|
17
|
+
yield(collector) if block_given?
|
18
|
+
assert_equal(expected, collector.send(:collect, *collect_args))
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_name
|
22
|
+
Test::Unit::Collector::Descendant::NAME
|
23
|
+
end
|
8
24
|
|
9
|
-
|
10
|
-
|
11
|
-
|
25
|
+
def empty_suite(name=nil)
|
26
|
+
Test::Unit::TestSuite.new(name || default_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
class TestCollect < self
|
30
|
+
def setup
|
31
|
+
super
|
32
|
+
|
33
|
+
@test_case1 = Class.new(Test::Unit::TestCase) do
|
34
|
+
def self.name
|
35
|
+
"test-case1"
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_1
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_2
|
42
|
+
end
|
12
43
|
end
|
13
44
|
|
14
|
-
|
45
|
+
@test_case2 = Class.new(Test::Unit::TestCase) do
|
46
|
+
def self.name
|
47
|
+
"test-case2"
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_0
|
51
|
+
end
|
15
52
|
end
|
16
53
|
|
17
|
-
|
54
|
+
@no_test_case = Class.new do
|
55
|
+
def self.name
|
56
|
+
"no-test-case"
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_4
|
60
|
+
end
|
18
61
|
end
|
19
62
|
end
|
20
63
|
|
21
|
-
|
22
|
-
|
23
|
-
"test-case2"
|
24
|
-
end
|
64
|
+
def test_basic
|
65
|
+
assert_collect(full_suite("name"), "name")
|
25
66
|
|
26
|
-
|
67
|
+
assert_collect(full_suite("name"), "name") do |collector|
|
68
|
+
collector.filter = []
|
27
69
|
end
|
28
70
|
end
|
29
71
|
|
30
|
-
|
31
|
-
|
32
|
-
|
72
|
+
def test_filtered
|
73
|
+
assert_collect(empty_suite) do |collector|
|
74
|
+
collector.filter = Proc.new {false}
|
33
75
|
end
|
34
76
|
|
35
|
-
|
77
|
+
assert_collect(full_suite) do |collector|
|
78
|
+
collector.filter = Proc.new {true}
|
36
79
|
end
|
37
|
-
end
|
38
|
-
end
|
39
80
|
|
40
|
-
|
41
|
-
|
42
|
-
|
81
|
+
assert_collect(full_suite) do |collector|
|
82
|
+
collector.filter = Proc.new {nil}
|
83
|
+
end
|
43
84
|
|
44
|
-
|
45
|
-
|
85
|
+
assert_collect(empty_suite) do |collector|
|
86
|
+
collector.filter = [Proc.new {false}, Proc.new {true}]
|
87
|
+
end
|
46
88
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
89
|
+
assert_collect(empty_suite) do |collector|
|
90
|
+
collector.filter = [Proc.new {true}, Proc.new {false}]
|
91
|
+
end
|
51
92
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
93
|
+
assert_collect(empty_suite) do |collector|
|
94
|
+
collector.filter = [Proc.new {nil}, Proc.new {false}]
|
95
|
+
end
|
56
96
|
|
57
|
-
|
58
|
-
|
59
|
-
|
97
|
+
assert_collect(full_suite) do |collector|
|
98
|
+
collector.filter = [Proc.new {nil}, Proc.new {true}]
|
99
|
+
end
|
60
100
|
|
61
|
-
|
62
|
-
|
63
|
-
|
101
|
+
expected = empty_suite
|
102
|
+
suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
103
|
+
suite1 << @test_case1.new("test_1")
|
104
|
+
suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
105
|
+
suite2 << @test_case2.new("test_0")
|
106
|
+
expected << suite1 << suite2
|
107
|
+
assert_collect(expected) do |collector|
|
108
|
+
collector.filter = Proc.new do |test|
|
109
|
+
['test_1', 'test_0'].include?(test.method_name)
|
110
|
+
end
|
111
|
+
end
|
64
112
|
|
65
|
-
|
66
|
-
|
113
|
+
suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
114
|
+
suite1 << @test_case1.new("test_1")
|
115
|
+
suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
116
|
+
suite2 << @test_case2.new("test_0")
|
117
|
+
assert_collect(empty_suite) do |collector|
|
118
|
+
filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
|
119
|
+
Proc.new {|test| test.method_name == 'test_0' ? true : nil},
|
120
|
+
Proc.new {false}]
|
121
|
+
collector.filter = filters
|
122
|
+
end
|
67
123
|
end
|
68
124
|
|
69
|
-
|
70
|
-
|
71
|
-
|
125
|
+
private
|
126
|
+
def full_suite(name=nil)
|
127
|
+
sub_suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
128
|
+
sub_suite1 << @test_case1.new('test_1')
|
129
|
+
sub_suite1 << @test_case1.new('test_2')
|
72
130
|
|
73
|
-
|
74
|
-
|
75
|
-
end
|
131
|
+
sub_suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
132
|
+
sub_suite2 << @test_case2.new('test_0')
|
76
133
|
|
77
|
-
|
78
|
-
|
134
|
+
suite = empty_suite(name)
|
135
|
+
suite << sub_suite1
|
136
|
+
suite << sub_suite2
|
137
|
+
suite
|
79
138
|
end
|
139
|
+
end
|
80
140
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
expected << suite1 << suite2
|
87
|
-
assert_collect(expected) do |collector|
|
88
|
-
collector.filter = Proc.new do |test|
|
89
|
-
['test_1', 'test_0'].include?(test.method_name)
|
141
|
+
class TestModule < self
|
142
|
+
def test_included_in_child
|
143
|
+
tests = Module.new do
|
144
|
+
def test_in_module
|
145
|
+
end
|
90
146
|
end
|
91
|
-
end
|
92
147
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
Proc.new {false}]
|
101
|
-
collector.filter = filters
|
102
|
-
end
|
103
|
-
end
|
148
|
+
parent_test_case = Class.new(Test::Unit::TestCase) do
|
149
|
+
class << self
|
150
|
+
def name
|
151
|
+
"Parent"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
104
155
|
|
105
|
-
|
106
|
-
|
107
|
-
collector = Test::Unit::Collector::Descendant.new
|
108
|
-
yield(collector) if block_given?
|
109
|
-
assert_equal(expected, collector.send(:collect, *collect_args))
|
110
|
-
end
|
156
|
+
child_test_case = Class.new(parent_test_case) do
|
157
|
+
include tests
|
111
158
|
|
112
|
-
|
113
|
-
|
114
|
-
|
159
|
+
class << self
|
160
|
+
def name
|
161
|
+
"Child"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
115
165
|
|
116
|
-
|
117
|
-
|
118
|
-
end
|
166
|
+
child_suite = Test::Unit::TestSuite.new(child_test_case.name)
|
167
|
+
child_suite << child_test_case.new("test_in_module")
|
119
168
|
|
120
|
-
|
121
|
-
|
122
|
-
sub_suite1 << @test_case1.new('test_1')
|
123
|
-
sub_suite1 << @test_case1.new('test_2')
|
169
|
+
parent_suite = Test::Unit::TestSuite.new(parent_test_case.name)
|
170
|
+
parent_suite << child_suite
|
124
171
|
|
125
|
-
|
126
|
-
|
172
|
+
suite = empty_suite("all")
|
173
|
+
suite << parent_suite
|
127
174
|
|
128
|
-
|
129
|
-
|
130
|
-
suite << sub_suite2
|
131
|
-
suite
|
175
|
+
assert_collect(suite, "all")
|
176
|
+
end
|
132
177
|
end
|
133
178
|
end
|
data/test/test-test-case.rb
CHANGED
@@ -159,6 +159,18 @@ module Test
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
+
def jruby?
|
163
|
+
defined?(JRUBY_VERSION)
|
164
|
+
end
|
165
|
+
|
166
|
+
def rubinius?
|
167
|
+
false # TODO
|
168
|
+
end
|
169
|
+
|
170
|
+
def cruby?
|
171
|
+
(not jruby?) and (not rubinius?)
|
172
|
+
end
|
173
|
+
|
162
174
|
def test_add_error
|
163
175
|
test_case = @tc_failure_error.new(:test_error)
|
164
176
|
assert do
|
@@ -180,15 +192,16 @@ module Test
|
|
180
192
|
:location => normalize_location(fault.location),
|
181
193
|
}
|
182
194
|
end
|
195
|
+
location = []
|
196
|
+
location << "#{__FILE__}:0:in `/'" if cruby?
|
197
|
+
location << "#{__FILE__}:0:in `test_error'"
|
198
|
+
location << "#{__FILE__}:0:in `#{__method__}'"
|
183
199
|
assert_equal([
|
184
200
|
{
|
185
201
|
:class => Error,
|
186
202
|
:message => "ZeroDivisionError: divided by 0",
|
187
203
|
:test_name => "test_error(TC_FailureError)",
|
188
|
-
:location =>
|
189
|
-
"#{__FILE__}:0:in `test_error'",
|
190
|
-
"#{__FILE__}:0:in `#{__method__}'",
|
191
|
-
],
|
204
|
+
:location => location,
|
192
205
|
},
|
193
206
|
],
|
194
207
|
fault_details)
|
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: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: power_assert
|