Class: TestMinitestUnitRecording

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_test.rb

Constant Summary

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

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, #setup, #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, #setup, #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 Method Details

#assert_run_record(*expected, &block) ⇒ Object

do not parallelize this suite… it just can’t handle it.



1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1150

def assert_run_record *expected, &block
  @tu = Class.new FakeNamedTest, &block

  run_tu_with_fresh_reporter

  recorded = first_reporter.results.map(&:failures).flatten.map { |f| f.error.class }

  assert_equal expected, recorded
end

#test_record_errorObject



1205
1206
1207
1208
1209
1210
1211
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1205

def test_record_error
  assert_run_record RuntimeError do
    def test_method
      raise "unhandled exception"
    end
  end
end

#test_record_error_in_test_and_teardownObject



1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1225

def test_record_error_in_test_and_teardown
  assert_run_record AnError, RuntimeError do
    def test_method
      raise AnError
    end

    def teardown
      raise "unhandled exception"
    end
  end
end

#test_record_error_teardownObject



1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1213

def test_record_error_teardown
  assert_run_record RuntimeError do
    def test_method
      assert true
    end

    def teardown
      raise "unhandled exception"
    end
  end
end

#test_record_failingObject



1197
1198
1199
1200
1201
1202
1203
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1197

def test_record_failing
  assert_run_record Minitest::Assertion do
    def test_method
      assert false
    end
  end
end

#test_record_passingObject



1189
1190
1191
1192
1193
1194
1195
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1189

def test_record_passing
  assert_run_record do
    def test_method
      assert true
    end
  end
end

#test_record_skipObject



1265
1266
1267
1268
1269
1270
1271
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1265

def test_record_skip
  assert_run_record Minitest::Skip do
    def test_method
      skip "not yet"
    end
  end
end

#test_run_with_bogus_reporterObject



1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1160

def test_run_with_bogus_reporter
  # https://github.com/seattlerb/minitest/issues/659
  # TODO: remove test for minitest 6
  @tu = Class.new FakeNamedTest do
    def test_method
      assert true
    end
  end

  bogus_reporter = Class.new do      # doesn't subclass AbstractReporter
    def start; @success = false; end
    # def prerecord klass, name; end # doesn't define full API
    def record result; @success = true; end
    def report; end
    def passed?; end
    def results; end
    def success?; @success; end
  end.new

  self.reporter = Minitest::CompositeReporter.new
  reporter << bogus_reporter

  Minitest::Runnable.runnables.delete @tu

  @tu.run reporter, {}

  assert_predicate bogus_reporter, :success?
end

#test_to_s_error_in_test_and_teardownObject



1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 1237

def test_to_s_error_in_test_and_teardown
  @tu = Class.new FakeNamedTest do
    def test_method
      raise AnError
    end

    def teardown
      raise "unhandled exception"
    end
  end

  run_tu_with_fresh_reporter

  exp = clean "
    Error:
    FakeNamedTestXX#test_method:
    AnError: AnError
        FILE:LINE:in `test_method'

    Error:
    FakeNamedTestXX#test_method:
    RuntimeError: unhandled exception
        FILE:LINE:in `teardown'
  "

  assert_equal exp.strip, normalize_output(first_reporter.results.first.to_s).strip
end