class Assert::Suite
This is the base suite. It loads the tests to run in memory and provides methods for these tests that the runner/view uses for handling and presentation purposes. It also stores suite-level setups and teardowns. Override the test/result count methods and the callbacks as needed. See the default suite for example usage.
Attributes
A suite is a set of tests to run. When a test class subclasses the Context
class, that test class is pushed to the suite.
A suite is a set of tests to run. When a test class subclasses the Context
class, that test class is pushed to the suite.
A suite is a set of tests to run. When a test class subclasses the Context
class, that test class is pushed to the suite.
Public Class Methods
# File lib/assert/suite.rb, line 21 def initialize(config) @config = config @tests = [] @setups = [] @teardowns = [] @start_time = Time.now @end_time = @start_time end
Public Instance Methods
# File lib/assert/suite.rb, line 111 def after_load end
# File lib/assert/suite.rb, line 123 def after_test(test) end
define callback handlers to do special behavior during the test run. These will be called by the test runner.
# File lib/assert/suite.rb, line 102 def before_load(test_files) end
# File lib/assert/suite.rb, line 117 def before_test(test) end
# File lib/assert/suite.rb, line 52 def clear_tests_to_run @tests.clear end
# File lib/assert/suite.rb, line 76 def error_result_count end
# File lib/assert/suite.rb, line 73 def fail_result_count end
# File lib/assert/suite.rb, line 56 def find_test_to_run(file_line) @tests.find{ |t| t.file_line == file_line } end
# File lib/assert/suite.rb, line 82 def ignore_result_count end
# File lib/assert/suite.rb, line 135 def inspect "#<#{self.class}:#{"0x0%x" % (object_id << 1)}"\ " test_count=#{test_count.inspect}"\ " result_count=#{result_count.inspect}>" end
# File lib/assert/suite.rb, line 126 def on_finish end
# File lib/assert/suite.rb, line 129 def on_info(test) end
# File lib/assert/suite.rb, line 132 def on_interrupt(err) end
# File lib/assert/suite.rb, line 120 def on_result(result) end
# File lib/assert/suite.rb, line 114 def on_start end
this is required to load tests into the suite, be sure to ‘super` if you override this method
# File lib/assert/suite.rb, line 107 def on_test(test) @tests << test end
# File lib/assert/suite.rb, line 70 def pass_result_count end
# File lib/assert/suite.rb, line 67 def result_count end
# File lib/assert/suite.rb, line 93 def result_rate get_rate(result_count, run_time) end
# File lib/assert/suite.rb, line 85 def run_time @end_time - @start_time end
# File lib/assert/suite.rb, line 34 def setup(&block) setups << (block || proc{}) end
# File lib/assert/suite.rb, line 79 def skip_result_count end
# File lib/assert/suite.rb, line 60 def sorted_tests_to_run(&sort_by_proc) @tests.sort.sort_by(&sort_by_proc) end
# File lib/assert/suite.rb, line 30 def suite self end
# File lib/assert/suite.rb, line 39 def teardown(&block) teardowns << (block || proc{}) end
# File lib/assert/suite.rb, line 64 def test_count end
# File lib/assert/suite.rb, line 89 def test_rate get_rate(test_count, run_time) end
# File lib/assert/suite.rb, line 44 def tests_to_run? @tests.any? end
# File lib/assert/suite.rb, line 48 def tests_to_run_count @tests.size end