class Tunit::Test
Constants
- PREFIX
Public Class Methods
order!()
click to toggle source
# File lib/tunit/test.rb, line 29 def self.order! class << self undef_method :test_order if method_defined?(:test_order) define_method(:test_order) { :alpha } end end
runnable_methods()
click to toggle source
# File lib/tunit/test.rb, line 11 def self.runnable_methods methods = methods_matching PREFIX case self.test_order when :random max = methods.size methods.sort.sort_by { rand max } when :alpha methods.sort else raise "Unknown test_order: #{self.test_order.inspect}" end end
test_order()
click to toggle source
Randomize tests by default
# File lib/tunit/test.rb, line 25 def self.test_order :random end
Public Instance Methods
code()
click to toggle source
# File lib/tunit/test.rb, line 72 def code failure && failure.result_code || "." end
failure()
click to toggle source
# File lib/tunit/test.rb, line 68 def failure self.failures.first end
location()
click to toggle source
# File lib/tunit/test.rb, line 76 def location loc = " [#{self.failure.location}]" unless passed? "#{self.class}##{self.name}#{loc}" end
passed?()
click to toggle source
# File lib/tunit/test.rb, line 60 def passed? !failure end
run()
click to toggle source
# File lib/tunit/test.rb, line 36 def run capture_exceptions do time_it do setup send name end if self.assertions.zero? begin fail ::Tunit::Empty, "Empty test, '#{self.to_s}'" rescue ::Tunit::Empty => e method_obj = self.method(name) e.location = method_obj.source_location.join(":") raise e end end end capture_exceptions do teardown end self end
skipped?()
click to toggle source
# File lib/tunit/test.rb, line 64 def skipped? failure && Skip === failure end
to_s()
click to toggle source
# File lib/tunit/test.rb, line 81 def to_s return location if passed? && !skipped? failures.map { |failure| "#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n" }.join "\n" end
Private Instance Methods
capture_exceptions() { || ... }
click to toggle source
# File lib/tunit/test.rb, line 98 def capture_exceptions yield rescue Assertion => e self.failures << e end
time_it() { || ... }
click to toggle source
# File lib/tunit/test.rb, line 91 def time_it t0 = Time.now yield ensure self.time = Time.now - t0 end