File: testunit-test-util.rb

package info (click to toggle)
ruby-test-unit 3.7.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,348 kB
  • sloc: ruby: 16,403; makefile: 9
file content (40 lines) | stat: -rw-r--r-- 938 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require "objspace"
require "tempfile"
require "bigdecimal"

module TestUnitTestUtil
  private
  def jruby?
    RUBY_PLATFORM == "java"
  end

  def jruby_only_test
    if jruby?
      require "java"
    else
      omit("test for JRuby")
    end
  end

  def assert_fault_messages(expected, faults)
    assert_equal(expected, faults.collect {|fault| fault.message})
  end

  def _run_test(test_case, name)
    result = Test::Unit::TestResult.new
    test = test_case.new(name)
    yield(test) if block_given?
    suite = Test::Unit::TestSuite.new(test_case.name, test_case)
    suite << test
    runner_class.run_all_tests(result, {test_suite: suite}) do |run_context|
      worker_context = Test::Unit::WorkerContext.new(nil, run_context, result)
      suite.run(worker_context) {}
    end
    result
  end

  def fixture_file_path(file_name)
    base_dir = File.dirname(__FILE__)
    File.join(base_dir, "fixtures", file_name)
  end
end