Sha256: 3e03c92b7edf4dfe8a9bcfa5b9dd9677b96109640a5c50af3e89fc06674f48e6
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
require 'test/unit/testcase' if defined?(MiniTest) require 'mocha/integration/mini_test' require File.expand_path('../mini_test_result', __FILE__) else require 'test/unit/testresult' end module TestRunner def run_test_case(test_class, test_result = nil) test = test_class.suite if defined?(Test::Unit::TestResult) test_result ||= Test::Unit::TestResult.new test.run(test_result) {} class << test_result attr_reader :failures, :errors def failure_messages failures.map { |failure| failure.message } end def failure_message_lines failure_messages.map { |message| message.split("\n") }.flatten end def error_messages errors.map { |error| error.message } end end else runner = MiniTest::Unit.new test.run(runner) test_result = MiniTestResult.new(runner, test) end test_result end def run_as_test(test_result = nil, &block) test_class = Class.new(Test::Unit::TestCase) do define_method(:test_me, &block) end run_test_case(test_class) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mocha-0.9.11 | test/test_runner.rb |