Object
Subclass TestCase to create your own tests. Typically you’ll want a TestCase subclass per implementation class.
Call this at the top of your tests when you absolutely positively need to have ordered tests. In doing so, you’re admitting that you suck and your tests are weak.
# File minitest/unit.rb, line 1273
def self.i_suck_and_my_tests_are_order_dependent!
class << self
undef_method :test_order if method_defined? :test_order
define_method :test_order do :alpha end
end
end
Return the output IO object
# File minitest/unit.rb, line 1250
def io
@__io__ = true
MiniTest::Unit.output
end
Have we hooked up the IO yet?
# File minitest/unit.rb, line 1258
def io?
@__io__
end
Returns true if the test passed.
# File minitest/unit.rb, line 1311
def passed?
@passed
end
Runs the tests reporting the status to runner
# File minitest/unit.rb, line 1193
def run runner
trap "INFO" do
runner.report.each_with_index do |msg, i|
warn "\n%3d) %s" % [i + 1, msg]
end
warn ''
time = runner.start_time ? Time.now - runner.start_time : 0
warn "Current Test: %s#%s %.2fs" % [self.class, self.__name__, time]
runner.status $stderr
end if SUPPORTS_INFO_SIGNAL
result = ""
begin
@passed = nil
self.before_setup
self.setup
self.after_setup
self.run_test self.__name__
result = "." unless io?
@passed = true
rescue *PASSTHROUGH_EXCEPTIONS
raise
rescue Exception => e
@passed = false
result = runner.puke self.class, self.__name__, e
ensure
%w{ before_teardown teardown after_teardown }.each do |hook|
begin
self.send hook
rescue *PASSTHROUGH_EXCEPTIONS
raise
rescue Exception => e
@passed = false
result = runner.puke self.class, self.__name__, e
end
end
trap 'INFO', 'DEFAULT' if SUPPORTS_INFO_SIGNAL
end
result
end
Commenting is here to help enhance the documentation. For example, sample code, or clarification of the documentation.
If you are posting code samples in your comments, please wrap them in "<pre><code class="ruby" > ... </code></pre>" markup in order to get syntax highlighting.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file a bug report so that it can be corrected for the next release. Thank you.