Class: TestUnitBackend

Inherits:
Backend show all
Defined in:
lib/backends/test_unit_backend.rb

Overview

Backend for gathering test results. Instead of ntalbott’s test/unit which ships with Ruby as of 1.8.6, this uses miniunit, a vastly simpler mostly-compatible replacement.

Class Method Summary collapse

Methods inherited from Backend

with_no_output, write_layers

Class Method Details

.failure_bucket(klass, method, exception) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/backends/test_unit_backend.rb', line 34

def failure_bucket(klass, method, exception)
  # FIXME: errors here could actually occur in impl rather than test file
  color = Test::Assertion === exception ? 'red' : 'yellow'
  line = exception.backtrace.grep(Regexp.new(@file))[0].match(/:(\d*):/)[1].to_i

  (@layers[@file] ||= []) << Layer.new(line, color, exception.message, self, @file)
end

.find_test_for(file) ⇒ Object

This should allow us to augment a test by running its associated implementation



44
45
46
47
# File 'lib/backends/test_unit_backend.rb', line 44

def find_test_for(file)
  # TODO: return test for implementation if possible
  file
end

.run(file) ⇒ Object

Kicks off a miniunit run and captures the failures



24
25
26
27
28
29
30
31
32
# File 'lib/backends/test_unit_backend.rb', line 24

def run(file)
  @file = file
  @layers = {}

  load(find_test_for(file))
  # this will call record_failure as needed
  with_no_output { Test::Unit.autotest }
  write_layers
end