Sha256: 6185fd3f53714d27dd6689a2b512d7f5c9c07a16430dab1d3a45b2b16c1b8788
Contents?: true
Size: 1.18 KB
Versions: 10
Compression:
Stored size: 1.18 KB
Contents
require 'test/unit/testcase' if defined?(MiniTest) require 'mocha/monkey_patching/mini_test' require File.expand_path('../mini_test_result', __FILE__) else require File.expand_path('../test_unit_result', __FILE__) end module TestRunner def run_as_test(&block) run_as_tests(block) end def run_as_tests(*procs) tests = procs.map do |proc| test_class = Class.new(Test::Unit::TestCase) do define_method(:test_me, proc) end test_class.new(:test_me) end if defined?(Test::Unit::TestResult) test_result = TestUnitResult.build_test_result tests.each do |test| test.run(test_result) {} end else runner = MiniTest::Unit.new tests.each do |test| test.run(runner) end test_result = MiniTestResult.new(runner, tests) end test_result end def assert_passed(test_result) flunk "Test failed unexpectedly with message: #{test_result.failures}" if test_result.failure_count > 0 flunk "Test failed unexpectedly with message: #{test_result.errors}" if test_result.error_count > 0 end def assert_failed(test_result) flunk "Test passed unexpectedly" if test_result.passed? end end
Version data entries
10 entries across 8 versions & 3 rubygems