Class: Turn::MiniRunner

### Home Classes Methods

### In Files

- lib/turn/runners/minirunner.rb

### Parent

MiniTest::Unit

### Methods

- ::new
- #_run_suite
- #_run_suites
- #output
- #puke
- #start
- #turn_reporter

### Files

- History.txt
- LICENSE-GPL2.txt
- LICENSE-MIT.txt
- LICENSE-RUBY.txt
- LICENSE.txt
- Release.txt
- Version.txt

### Class/Module Index

Quicksearch

- Turn
- Turn::Colorize
- Turn::Command
- Turn::Configuration
- Turn::Controller
- Turn::CrossRunner
- Turn::CueReporter
- Turn::DotReporter
- Turn::IsoRunner
- Turn::MarshalReporter
- Turn::MiniRunner
- Turn::OutlineReporter
- Turn::PrettyReporter
- Turn::ProgressReporter
- Turn::Reporter
- Turn::SoloRunner
- Turn::TestCase
- Turn::TestMethod
- Turn::TestRunner
- Turn::TestSuite
- Test
- Test::Unit
- Test::Unit::Failure
- Object
- String

No matching classes.

# Turn::MiniRunner

Turn's MiniTest test runner class.

### Public Class Methods

new() click to toggle source

    # File lib/turn/runners/minirunner.rb, line 15
    def initialize
      @turn_config = Turn.config

      super()

      # a stream we will use to route minitests traditional output
      @out = ::StringIO.new
    end

### Public Instance Methods

_run_suite(suite, type) click to toggle source

Override #_run_suite to iterate tests via Turn.

    # File lib/turn/runners/minirunner.rb, line 69
    def _run_suite suite, type
      # suites are cases in minitest
      @turn_case = @turn_suite.new_case(suite.name)

      filter = @options[:filter] || @turn_config.pattern || /./

      suite.send("#{type}_methods").grep(filter).each do |test|
        @turn_case.new_test(test)
      end

      turn_reporter.start_case(@turn_case)

      header = "#{type}_suite_header"
      puts send(header, suite) if respond_to? header

      assertions = @turn_case.tests.map do |test|
        @turn_test = test
        turn_reporter.start_test(@turn_test)

        inst = suite.new(test.name) #method
        inst._assertions = 0

        result = inst.run self

        if result == "."
          turn_reporter.pass
        end

        turn_reporter.finish_test(@turn_test)

        inst._assertions
      end

      @turn_case.count_assertions = assertions.inject(0) { |sum, n| sum + n }

      turn_reporter.finish_case(@turn_case)

      return assertions.size, assertions.inject(0) { |sum, n| sum + n }
    end

_run_suites(suites, type) click to toggle source

Override #_run_suite to setup Turn.

    # File lib/turn/runners/minirunner.rb, line 46
    def _run_suites suites, type
      # Someone want to explain to me why these are fucking here?
      suites = suites - [MiniTest::Spec]
      suites = suites - [Test::Unit::TestCase] if defined?(Test::Unit::TestCase)

      @turn_suite = Turn::TestSuite.new(@turn_config.suite_name)
      @turn_suite.size = suites.size  #::MiniTest::Unit::TestCase.test_suites.size
      @turn_suite.seed = ::MiniTest::Unit.runner.options[:seed]

      turn_reporter.start_suite(@turn_suite)

      if @turn_config.matchcase
        suites = suites.select{ |suite| @turn_config.matchcase =~ suite.name }
      end

      result = suites.map { |suite| _run_suite(suite, type) }

      turn_reporter.finish_suite(@turn_suite)

      return result
    end

output() click to toggle source

route minitests traditional output to nowhere

    # File lib/turn/runners/minirunner.rb, line 25
    def output
      @out
    end

puke(klass, meth, err) click to toggle source

Override puke to update Turn's internals and reporter.

    # File lib/turn/runners/minirunner.rb, line 110
    def puke(klass, meth, err)
      case err
      when MiniTest::Skip
        @turn_test.skip!(err)
        turn_reporter.skip(err)
      when MiniTest::Assertion
        @turn_test.fail!(err)
        turn_reporter.fail(err)
      else
        @turn_test.error!(err)
        turn_reporter.error(err)
      end
      super(klass, meth, err)
    end

start(args=[]) click to toggle source

Turn calls this method to start the test run.

    # File lib/turn/runners/minirunner.rb, line 35
    def start(args=[])
      # minitest changed #run in 6023c879cf3d5169953e on April 6th, 2011
      if ::MiniTest::Unit.respond_to?(:runner=)
        ::MiniTest::Unit.runner = self
      end
      # FIXME: why isn't @test_count set?
      run(args)
      return @turn_suite
    end

turn_reporter() click to toggle source

    # File lib/turn/runners/minirunner.rb, line 30
    def turn_reporter
      @turn_config.reporter
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.