Sha256: dc4662f11afe343c102b538a7e7c168949804f574184e3004b87ca1d03ff9934

Contents?: true

Size: 1.09 KB

Versions: 41

Compression:

Stored size: 1.09 KB

Contents

require 'test/unit'
require 'test/unit/testresult'

Test::Unit.run = true # This stops testunit from running the file as soon as it is included. Yep. That's correct. True.

module GorgonTestCases
  def self.cases
    @gorgon_cases ||= []
  end

  def self.clear_cases!
    @gorgon_cases = []
  end
end


if defined? ActiveSupport::TestCase
  class ActiveSupport::TestCase
    def self.inherited(klass)
      GorgonTestCases.cases << klass
    end
  end
end

class Test::Unit::TestCase
  def self.inherited(klass)
    GorgonTestCases.cases << klass
  end
end

class TestUnitRunner
  def self.run_file(filename)
    GorgonTestCases.clear_cases!
    load filename

    result = Test::Unit::TestResult.new
    output = []
    result.add_listener(Test::Unit::TestResult::FAULT) do |value|
      output << value
    end

    GorgonTestCases.cases.each do |klass|
      # Not all descendants of TestCase are actually runnable, but they do all implement #suite
      # Calling suite.run will give us only runnable tests
      klass.suite.run(result) {|s,n|;}
    end

    output
  end

  def self.runner
    :test_unit
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
gorgon-0.11.1 lib/gorgon/test_unit_runner.rb
gorgon-0.11.0 lib/gorgon/test_unit_runner.rb
gorgon-0.10.5 lib/gorgon/test_unit_runner.rb
gorgon-0.10.4 lib/gorgon/test_unit_runner.rb
gorgon-0.10.3 lib/gorgon/test_unit_runner.rb
gorgon-0.10.2 lib/gorgon/test_unit_runner.rb
gorgon-0.10.1 lib/gorgon/test_unit_runner.rb
gorgon-0.10.0 lib/gorgon/test_unit_runner.rb
gorgon-0.9.0 lib/gorgon/test_unit_runner.rb
gorgon-0.8.4 lib/gorgon/test_unit_runner.rb
gorgon-0.8.3 lib/gorgon/test_unit_runner.rb
gorgon-0.8.2 lib/gorgon/test_unit_runner.rb
gorgon-0.8.1 lib/gorgon/test_unit_runner.rb
gorgon-0.8.0 lib/gorgon/test_unit_runner.rb
gorgon-0.7.1 lib/gorgon/test_unit_runner.rb
gorgon-0.7.0 lib/gorgon/test_unit_runner.rb
gorgon-0.7.0.rc4 lib/gorgon/test_unit_runner.rb
gorgon-0.7.0.rc3 lib/gorgon/test_unit_runner.rb
gorgon-0.7.0.rc2 lib/gorgon/test_unit_runner.rb
gorgon-0.7.0.rc1 lib/gorgon/test_unit_runner.rb