Class: TestMinitestReporter

Inherits:
MetaMetaMetaTestCase show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb

Constant Summary collapse

SKIP_MSG =
"\n\nYou have skipped tests. Run with --verbose for details."

Constants inherited from Minitest::Test

Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS

Constants included from Minitest::Assertions

Minitest::Assertions::E, Minitest::Assertions::UNDEFINED

Constants inherited from Minitest::Runnable

Minitest::Runnable::SIGNALS

Instance Attribute Summary collapse

Attributes inherited from MetaMetaMetaTestCase

#output, #reporter, #tu

Attributes inherited from Minitest::Runnable

#assertions, #failures, #time

Instance Method Summary collapse

Methods inherited from MetaMetaMetaTestCase

#assert_report, #first_reporter, #normalize_output, #restore_env, #run_tu_with_fresh_reporter, #with_stderr

Methods inherited from Minitest::Test

#capture_exceptions, #class_name, #clean, i_suck_and_my_tests_are_order_dependent!, make_my_diffs_pretty!, #neuter_exception, #new_exception, parallelize_me!, #run, runnable_methods, #sanitize_exception, test_order, #with_empty_backtrace_filter, #with_info_handler

Methods included from Minitest::Guard

#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?

Methods included from Minitest::Test::LifecycleHooks

#after_setup, #after_teardown, #before_setup, #before_teardown, #teardown

Methods included from Minitest::Reportable

#class_name, #error?, #location, #passed?, #result_code, #skipped?

Methods included from Minitest::Assertions

#_synchronize, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_mock, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #fail_after, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_path_exists, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skip_until, #skipped?, #things_to_diff

Methods inherited from Minitest::Runnable

#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, run_one_method, runnable_methods, runnables, #skipped?, #time_it, #whatever, with_info_handler

Constructor Details

This class inherits a constructor from Minitest::Runnable

Instance Attribute Details

#ioObject

Returns the value of attribute io.



13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 13

def io
  @io
end

#rObject

Returns the value of attribute r.



13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 13

def r
  @r
end

Instance Method Details

#error_testObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 38

def error_test
  unless defined? @et then
    @et = Minitest::Test.new(:woot)
    @et.failures << Minitest::UnexpectedError.new(begin
                                                    raise "no"
                                                  rescue => e
                                                    e
                                                  end)
    @et = Minitest::Result.from @et
  end
  @et
end

#fail_testObject



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 51

def fail_test
  unless defined? @ft then
    @ft = Minitest::Test.new(:woot)
    @ft.failures <<   begin
                        raise Minitest::Assertion, "boo"
                      rescue Minitest::Assertion => e
                        e
                      end
    @ft = Minitest::Result.from @ft
  end
  @ft
end

#new_composite_reporterObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 15

def new_composite_reporter
  # Ruby bug in older versions of 2.2 & 2.3 on all platforms
  # Latest Windows builds were 2.2.6 and 2.3.3.  Latest Ruby releases were
  # 2.2.10 and 2.3.8.
  skip if windows? && RUBY_VERSION < '2.4'
  reporter = Minitest::CompositeReporter.new
  reporter << Minitest::SummaryReporter.new(self.io)
  reporter << Minitest::ProgressReporter.new(self.io)

  # eg reporter.results -> reporters.first.results
  reporter.extend Forwardable
  reporter.delegate :first => :reporters
  reporter.delegate %i[results count assertions options to_s] => :first

  reporter
end

#passing_testObject



64
65
66
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 64

def passing_test
  @pt ||= Minitest::Result.from Minitest::Test.new(:woot)
end

#setupObject



32
33
34
35
36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 32

def setup
  super
  self.io = StringIO.new("")
  self.r  = new_composite_reporter
end

#skip_testObject



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 68

def skip_test
  unless defined? @st then
    @st = Minitest::Test.new(:woot)
    @st.failures << begin
                      raise Minitest::Skip
                    rescue Minitest::Assertion => e
                      e
                    end
    @st = Minitest::Result.from @st
  end
  @st
end

#test_options_skip_EObject



96
97
98
99
100
101
102
103
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 96

def test_options_skip_E
  r.options[:skip] = "E"

  r.record passing_test
  r.record error_test

  refute_match "RuntimeError: no", r.to_s
end

#test_options_skip_FObject



87
88
89
90
91
92
93
94
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 87

def test_options_skip_F
  r.options[:skip] = "F"

  r.record passing_test
  r.record fail_test

  refute_match "woot", r.to_s
end

#test_passed_eh_emptyObject



105
106
107
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 105

def test_passed_eh_empty
  assert_predicate r, :passed?
end

#test_passed_eh_errorObject



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 117

def test_passed_eh_error
  r.start

  r.results << error_test

  refute_predicate r, :passed?

  r.report

  refute_match SKIP_MSG, io.string
end

#test_passed_eh_failureObject



109
110
111
112
113
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 109

def test_passed_eh_failure
  r.results << fail_test

  refute_predicate r, :passed?
end

#test_passed_eh_skippedObject



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 129

def test_passed_eh_skipped
  r.start
  r.results << skip_test
  assert r.passed?

  restore_env do
    r.report
  end

  assert_match SKIP_MSG, io.string
end

#test_passed_eh_skipped_verboseObject



141
142
143
144
145
146
147
148
149
150
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 141

def test_passed_eh_skipped_verbose
  r.options[:verbose] = true

  r.start
  r.results << skip_test
  assert r.passed?
  r.report

  refute_match SKIP_MSG, io.string
end

#test_record_errorObject



179
180
181
182
183
184
185
186
187
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 179

def test_record_error
  error_test = self.error_test
  r.record error_test

  assert_equal "E", io.string
  assert_equal [error_test], r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end

#test_record_failObject



169
170
171
172
173
174
175
176
177
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 169

def test_record_fail
  fail_test = self.fail_test
  r.record fail_test

  assert_equal "F", io.string
  assert_equal [fail_test], r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end

#test_record_passObject



160
161
162
163
164
165
166
167
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 160

def test_record_pass
  r.record passing_test

  assert_equal ".", io.string
  assert_empty r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end

#test_record_skipObject



189
190
191
192
193
194
195
196
197
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 189

def test_record_skip
  skip_test = self.skip_test
  r.record skip_test

  assert_equal "S", io.string
  assert_equal [skip_test], r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end

#test_report_emptyObject



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 199

def test_report_empty
  r.start
  r.report

  exp = clean <<-EOM
    Run options:

    # Running:



    Finished in 0.00

    0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
  EOM

  assert_equal exp, normalize_output(io.string)
end

#test_report_errorObject



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 262

def test_report_error
  r.start
  r.record error_test
  r.report

  exp = clean <<-EOM
    Run options:

    # Running:

    E

    Finished in 0.00

      1) Error:
    Minitest::Test#woot:
    RuntimeError: no
        FILE:LINE:in `error_test'
        FILE:LINE:in `test_report_error'

    1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
  EOM

  assert_equal exp, normalize_output(io.string)
end

#test_report_failureObject



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 238

def test_report_failure
  r.start
  r.record fail_test
  r.report

  exp = clean <<-EOM
    Run options:

    # Running:

    F

    Finished in 0.00

      1) Failure:
    Minitest::Test#woot [FILE:LINE]:
    boo

    1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
  EOM

  assert_equal exp, normalize_output(io.string)
end

#test_report_passingObject



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 218

def test_report_passing
  r.start
  r.record passing_test
  r.report

  exp = clean <<-EOM
    Run options:

    # Running:

    .

    Finished in 0.00

    1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
  EOM

  assert_equal exp, normalize_output(io.string)
end

#test_report_skippedObject



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 288

def test_report_skipped
  r.start
  r.record skip_test

  restore_env do
    r.report
  end

  exp = clean <<-EOM
    Run options:

    # Running:

    S

    Finished in 0.00

    1 runs, 0 assertions, 0 failures, 0 errors, 1 skips

    You have skipped tests. Run with --verbose for details.
  EOM

  assert_equal exp, normalize_output(io.string)
end

#test_startObject



152
153
154
155
156
157
158
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 152

def test_start
  r.start

  exp = "Run options: \n\n# Running:\n\n"

  assert_equal exp, io.string
end

#test_to_sObject



81
82
83
84
85
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_reporter.rb', line 81

def test_to_s
  r.record passing_test
  r.record fail_test
  assert_match "woot", r.to_s
end