spec 5.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +34 -0
- data/.gitignore +3 -0
- data/History.txt +911 -0
- data/Manifest.txt +26 -0
- data/README.txt +497 -0
- data/Rakefile +214 -0
- data/design_rationale.rb +52 -0
- data/lib/hoe/minitest.rb +26 -0
- data/lib/minitest/assertions.rb +649 -0
- data/lib/minitest/autorun.rb +12 -0
- data/lib/minitest/benchmark.rb +423 -0
- data/lib/minitest/expectations.rb +268 -0
- data/lib/minitest/hell.rb +11 -0
- data/lib/minitest/mock.rb +220 -0
- data/lib/minitest/parallel_each.rb +120 -0
- data/lib/minitest/pride.rb +4 -0
- data/lib/minitest/pride_plugin.rb +143 -0
- data/lib/minitest/spec.rb +292 -0
- data/lib/minitest/test.rb +272 -0
- data/lib/minitest/unit.rb +45 -0
- data/lib/minitest.rb +839 -0
- data/lib/spec.rb +3 -0
- data/readme.md +7 -0
- data/release_notes.md +49 -0
- data/spec.gemspec +36 -0
- data/test/manual/appium.rb +14 -0
- data/test/manual/appium_after_last.rb +24 -0
- data/test/manual/appium_before_first.rb +23 -0
- data/test/manual/assert.rb +61 -0
- data/test/manual/before_first_0.rb +27 -0
- data/test/manual/before_first_1.rb +29 -0
- data/test/manual/debug.rb +37 -0
- data/test/manual/do_end.rb +31 -0
- data/test/manual/raise.rb +61 -0
- data/test/manual/run2.rb +74 -0
- data/test/manual/run3.rb +91 -0
- data/test/manual/setup.rb +13 -0
- data/test/manual/simple.rb +19 -0
- data/test/manual/simple2.rb +20 -0
- data/test/manual/t.rb +11 -0
- data/test/manual/trace.rb +19 -0
- data/test/manual/trace2.rb +15 -0
- data/test/minitest/metametameta.rb +78 -0
- data/test/minitest/test_helper.rb +20 -0
- data/test/minitest/test_minitest_benchmark.rb +131 -0
- data/test/minitest/test_minitest_mock.rb +490 -0
- data/test/minitest/test_minitest_reporter.rb +270 -0
- data/test/minitest/test_minitest_spec.rb +794 -0
- data/test/minitest/test_minitest_unit.rb +1846 -0
- metadata +147 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/metametameta"
|
3
|
+
require 'minitest/test_helper'
|
4
|
+
|
5
|
+
class TestMinitestReporter < Minitest::Test
|
6
|
+
|
7
|
+
attr_accessor :r, :io
|
8
|
+
|
9
|
+
def new_composite_reporter
|
10
|
+
reporter = Minitest::CompositeReporter.new
|
11
|
+
reporter << Minitest::SummaryReporter.new(self.io)
|
12
|
+
reporter << Minitest::ProgressReporter.new(self.io)
|
13
|
+
|
14
|
+
def reporter.first
|
15
|
+
reporters.first
|
16
|
+
end
|
17
|
+
|
18
|
+
def reporter.results
|
19
|
+
first.results
|
20
|
+
end
|
21
|
+
|
22
|
+
def reporter.count
|
23
|
+
first.count
|
24
|
+
end
|
25
|
+
|
26
|
+
def reporter.assertions
|
27
|
+
first.assertions
|
28
|
+
end
|
29
|
+
|
30
|
+
reporter
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup
|
34
|
+
self.io = StringIO.new("")
|
35
|
+
self.r = new_composite_reporter
|
36
|
+
end
|
37
|
+
|
38
|
+
def error_test
|
39
|
+
unless defined? @et then
|
40
|
+
@et = Minitest::Test.new(:woot)
|
41
|
+
@et.failures << Minitest::UnexpectedError.new(begin
|
42
|
+
raise "no"
|
43
|
+
rescue => e
|
44
|
+
e
|
45
|
+
end)
|
46
|
+
end
|
47
|
+
@et
|
48
|
+
end
|
49
|
+
|
50
|
+
def fail_test
|
51
|
+
unless defined? @ft then
|
52
|
+
@ft = Minitest::Test.new(:woot)
|
53
|
+
@ft.failures << begin
|
54
|
+
raise Minitest::Assertion, "boo"
|
55
|
+
rescue Minitest::Assertion => e
|
56
|
+
e
|
57
|
+
end
|
58
|
+
end
|
59
|
+
@ft
|
60
|
+
end
|
61
|
+
|
62
|
+
def passing_test
|
63
|
+
@pt ||= Minitest::Test.new(:woot)
|
64
|
+
end
|
65
|
+
|
66
|
+
def skip_test
|
67
|
+
unless defined? @st then
|
68
|
+
@st = Minitest::Test.new(:woot)
|
69
|
+
@st.failures << Minitest::Skip.new
|
70
|
+
end
|
71
|
+
@st
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_passed_eh_empty
|
75
|
+
assert r.passed?
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_passed_eh_failure
|
79
|
+
r.results << fail_test
|
80
|
+
|
81
|
+
refute r.passed?
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_passed_eh_error
|
85
|
+
r.results << error_test
|
86
|
+
|
87
|
+
refute r.passed?
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_passed_eh_skipped
|
91
|
+
r.results << skip_test
|
92
|
+
|
93
|
+
assert r.passed?
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_start
|
97
|
+
r.start
|
98
|
+
|
99
|
+
exp = "Run options: \n\n# Running:\n\n"
|
100
|
+
|
101
|
+
assert_equal exp, io.string
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_record_pass
|
105
|
+
r.record passing_test
|
106
|
+
|
107
|
+
assert_equal ".", io.string
|
108
|
+
assert_empty r.results
|
109
|
+
assert_equal 1, r.count
|
110
|
+
assert_equal 0, r.assertions
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_record_fail
|
114
|
+
r.record fail_test
|
115
|
+
|
116
|
+
assert_equal "F", io.string
|
117
|
+
assert_equal [fail_test], r.results
|
118
|
+
assert_equal 1, r.count
|
119
|
+
assert_equal 0, r.assertions
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_record_error
|
123
|
+
r.record error_test
|
124
|
+
|
125
|
+
assert_equal "E", io.string
|
126
|
+
assert_equal [error_test], r.results
|
127
|
+
assert_equal 1, r.count
|
128
|
+
assert_equal 0, r.assertions
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_record_skip
|
132
|
+
r.record skip_test
|
133
|
+
|
134
|
+
assert_equal "S", io.string
|
135
|
+
assert_equal [skip_test], r.results
|
136
|
+
assert_equal 1, r.count
|
137
|
+
assert_equal 0, r.assertions
|
138
|
+
end
|
139
|
+
|
140
|
+
def normalize_output output
|
141
|
+
output.sub!(/Finished in .*/, "Finished in 0.00")
|
142
|
+
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
|
143
|
+
|
144
|
+
output.gsub!(/ = \d+.\d\d s = /, ' = 0.00 s = ')
|
145
|
+
output.gsub!(/0x[A-Fa-f0-9]+/, '0xXXX')
|
146
|
+
output.gsub!(/ +$/, '')
|
147
|
+
|
148
|
+
if windows? then
|
149
|
+
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]')
|
150
|
+
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
|
151
|
+
else
|
152
|
+
output.gsub!(/\[[^\]:]+:\d+\]/, '[FILE:LINE]')
|
153
|
+
output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
|
154
|
+
end
|
155
|
+
|
156
|
+
output
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_report_empty
|
160
|
+
r.start
|
161
|
+
r.report
|
162
|
+
|
163
|
+
exp = clean <<-EOM
|
164
|
+
Run options:
|
165
|
+
|
166
|
+
# Running:
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
Finished in 0.00
|
171
|
+
|
172
|
+
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
|
173
|
+
EOM
|
174
|
+
|
175
|
+
|
176
|
+
assert_equal exp, normalize_output(io.string)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_report_passing
|
180
|
+
r.start
|
181
|
+
r.record passing_test
|
182
|
+
r.report
|
183
|
+
|
184
|
+
exp = clean <<-EOM
|
185
|
+
Run options:
|
186
|
+
|
187
|
+
# Running:
|
188
|
+
|
189
|
+
.
|
190
|
+
|
191
|
+
Finished in 0.00
|
192
|
+
|
193
|
+
1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
|
194
|
+
EOM
|
195
|
+
|
196
|
+
|
197
|
+
assert_equal exp, normalize_output(io.string)
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_report_failure
|
201
|
+
r.start
|
202
|
+
r.record fail_test
|
203
|
+
r.report
|
204
|
+
|
205
|
+
exp = clean <<-EOM
|
206
|
+
Run options:
|
207
|
+
|
208
|
+
# Running:
|
209
|
+
|
210
|
+
F
|
211
|
+
|
212
|
+
Finished in 0.00
|
213
|
+
|
214
|
+
1) Failure:
|
215
|
+
Minitest::Test#woot [FILE:LINE]:
|
216
|
+
boo
|
217
|
+
|
218
|
+
1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
|
219
|
+
EOM
|
220
|
+
|
221
|
+
|
222
|
+
assert_equal exp, normalize_output(io.string)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_report_error
|
226
|
+
r.start
|
227
|
+
r.record error_test
|
228
|
+
r.report
|
229
|
+
|
230
|
+
exp = clean <<-EOM
|
231
|
+
Run options:
|
232
|
+
|
233
|
+
# Running:
|
234
|
+
|
235
|
+
E
|
236
|
+
|
237
|
+
Finished in 0.00
|
238
|
+
|
239
|
+
1) Error:
|
240
|
+
Minitest::Test#woot:
|
241
|
+
RuntimeError: no
|
242
|
+
FILE:LINE:in `error_test'
|
243
|
+
FILE:LINE:in `test_report_error'
|
244
|
+
|
245
|
+
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
246
|
+
EOM
|
247
|
+
|
248
|
+
assert_equal exp, normalize_output(io.string)
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_report_skipped
|
252
|
+
r.start
|
253
|
+
r.record skip_test
|
254
|
+
r.report
|
255
|
+
|
256
|
+
exp = clean <<-EOM
|
257
|
+
Run options:
|
258
|
+
|
259
|
+
# Running:
|
260
|
+
|
261
|
+
S
|
262
|
+
|
263
|
+
Finished in 0.00
|
264
|
+
|
265
|
+
1 runs, 0 assertions, 0 failures, 0 errors, 1 skips
|
266
|
+
EOM
|
267
|
+
|
268
|
+
assert_equal exp, normalize_output(io.string)
|
269
|
+
end
|
270
|
+
end
|