lib/turn/runners/testrunner.rb in turn-0.7.0 vs lib/turn/runners/testrunner.rb in turn-0.8.0
- old
+ new
@@ -6,34 +6,40 @@
#require 'turn/components/case.rb'
#require 'turn/components/method.rb'
#require 'turn/reporters/outline_reporter.rb'
#require 'turn/reporters/progress_reporter.rb'
+class Test::Unit::Failure
+ alias_method :backtrace, :location
+end
+
module Turn
# = TestUnit TestRunner
#
- #--
- # TODO: Add minitest runner.
- #++
class TestRunner < ::Test::Unit::UI::Console::TestRunner
def initialize(controller)
output_level = 2 # 2-NORMAL 3-VERBOSE
controller.loadpath.each{ |path| $: << path } unless controller.live?
controller.requires.each{ |path| require(path) }
- [controller.files].flatten.each{ |path| require(path) }
+ files = [controller.files].flatten
+ files.each{ |path| require(path) }
+ # TODO: Better name ?
+ name = files.map{ |path| File.dirname(path).sub(Dir.pwd+'/','') }.uniq.join(',')
+
sub_suites = []
ObjectSpace.each_object(Class) do |klass|
if(Test::Unit::TestCase > klass)
sub_suites << klass.suite
end
end
- suite = Test::Unit::TestSuite.new('') # FIXME: Name?
+ suite = Test::Unit::TestSuite.new(name)
+
sub_suites.sort_by{|s|s.name}.each{|s| suite << s}
suite.tests.each do |c|
pattern = controller.pattern
c.tests.reject! { |t| pattern !~ t.method_name }
@@ -59,18 +65,20 @@
@io.sync = true
@t_result = nil
@t_fault = nil
+ @not_first_case = nil
+
@t_previous_run_count = 0
@t_previous_error_count = 0
@t_previous_failure_count = 0
@t_previous_assertion_count = 0
end
def t_started(result)
- @t_suite = Turn::TestSuite.new #@suite
+ @t_suite = Turn::TestSuite.new(@suite.name)
@t_suite.size = @suite.size
@t_result = result
@t_reporter.start_suite(@t_suite)
end
@@ -90,20 +98,20 @@
end
def t_fault(fault)
case fault
when ::Test::Unit::Error
- msg = ""
- msg << fault.to_s.split("\n")[2..-1].join("\n")
- @t_test.error!(msg)
- @t_reporter.error(msg)
+ #msg = ""
+ #msg << fault.to_s.split("\n")[2..-1].join("\n")
+ @t_test.error!(fault.exception)
+ @t_reporter.error(fault.exception)
when ::Test::Unit::Failure
- msg = ""
- msg << fault.location[0] << "\n"
- msg << fault.message #.gsub("\n","\n")
- @t_test.fail!(msg)
- @t_reporter.fail(msg)
+ #msg = ""
+ #msg << fault.location[0] << "\n"
+ #msg << fault.message #.gsub("\n","\n")
+ @t_test.fail!(fault)
+ @t_reporter.fail(fault)
end
end
def t_test_finished(name)
@t_reporter.pass if @t_test.pass?
@@ -116,10 +124,9 @@
#t = @t_result.run_count - @t_previous_run_count
#f = @t_result.failure_count - @t_previous_failure_count
#e = @t_result.error_count - @t_previous_error_count
a = @t_result.assertion_count - @t_previous_assertion_count
-
#@t_case.counts(t,a,f,e)
@t_case.count_assertions = a
#@t_previous_run_count = @t_result.run_count.to_i