Class: Assert::Suite

Inherits:
Object
  • Object
show all
Includes:
ConfigHelpers
Defined in:
lib/assert/suite.rb

Direct Known Subclasses

DefaultSuite

Constant Summary collapse

TEST_METHOD_REGEX =
/^test./.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigHelpers

#all_pass?, #formatted_result_rate, #formatted_run_time, #formatted_test_rate, #ocurring_result_types, #runner, #runner_seed, #show_test_profile_info?, #show_test_verbose_info?, #single_test?, #single_test_file_line, #tests?, #view

Constructor Details

#initialize(config) ⇒ Suite

Returns a new instance of Suite.



17
18
19
20
21
22
23
24
25
# File 'lib/assert/suite.rb', line 17

def initialize(config)
  @config       = config
  @tests        = []
  @test_methods = []
  @setups       = []
  @teardowns    = []
  @start_time   = Time.now
  @end_time     = @start_time
end

Instance Attribute Details

#configObject (readonly)

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.



14
15
16
# File 'lib/assert/suite.rb', line 14

def config
  @config
end

#end_timeObject

Returns the value of attribute end_time.



15
16
17
# File 'lib/assert/suite.rb', line 15

def end_time
  @end_time
end

#setupsObject (readonly)

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.



14
15
16
# File 'lib/assert/suite.rb', line 14

def setups
  @setups
end

#start_timeObject

Returns the value of attribute start_time.



15
16
17
# File 'lib/assert/suite.rb', line 15

def start_time
  @start_time
end

#teardownsObject (readonly)

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.



14
15
16
# File 'lib/assert/suite.rb', line 14

def teardowns
  @teardowns
end

#test_methodsObject (readonly)

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.



14
15
16
# File 'lib/assert/suite.rb', line 14

def test_methods
  @test_methods
end

#testsObject (readonly)

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.



14
15
16
# File 'lib/assert/suite.rb', line 14

def tests
  @tests
end

Instance Method Details

#after_loadObject



93
# File 'lib/assert/suite.rb', line 93

def after_load;              end

#after_test(test) ⇒ Object



97
# File 'lib/assert/suite.rb', line 97

def after_test(test);        end

#before_load(test_files) ⇒ Object

define callback handlers to do special behavior during the test run. These will be called by the test runner



92
# File 'lib/assert/suite.rb', line 92

def before_load(test_files); end

#before_test(test) ⇒ Object



95
# File 'lib/assert/suite.rb', line 95

def before_test(test);       end

#count(thing) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/assert/suite.rb', line 51

def count(thing)
  if thing == :tests
    test_count
  elsif thing == :results
    result_count
  elsif thing == :pass   || thing == :passed
    result_count(:pass)
  elsif thing == :fail   || thing == :failed
    result_count(:fail)
  elsif thing == :error  || thing == :errored
    result_count(:error)
  elsif thing == :skip   || thing == :skipped
    result_count(:skip)
  elsif thing == :ignore || thing == :ignored
    result_count(:ignore)
  else
    0
  end
end

#inspectObject



101
102
103
104
105
# File 'lib/assert/suite.rb', line 101

def inspect
  "#<#{self.class}:#{'0x0%x' % (object_id << 1)}"\
  " test_count=#{self.test_count.inspect}"\
  " result_count=#{self.result_count.inspect}>"
end

#on_finishObject



98
# File 'lib/assert/suite.rb', line 98

def on_finish;               end

#on_interrupt(err) ⇒ Object



99
# File 'lib/assert/suite.rb', line 99

def on_interrupt(err);       end

#on_result(result) ⇒ Object



96
# File 'lib/assert/suite.rb', line 96

def on_result(result);       end

#on_startObject



94
# File 'lib/assert/suite.rb', line 94

def on_start;                end

#ordered_resultsObject

Result data



81
# File 'lib/assert/suite.rb', line 81

def ordered_results;           end

#ordered_results_for_dumpObject



83
# File 'lib/assert/suite.rb', line 83

def ordered_results_for_dump;  end

#ordered_testsObject

Test data



73
# File 'lib/assert/suite.rb', line 73

def ordered_tests;              end

#ordered_tests_by_run_timeObject



75
# File 'lib/assert/suite.rb', line 75

def ordered_tests_by_run_time;  end

#result_count(type = nil) ⇒ Object



85
# File 'lib/assert/suite.rb', line 85

def result_count(type = nil);  end

#result_rateObject



47
48
49
# File 'lib/assert/suite.rb', line 47

def result_rate
  get_rate(self.result_count, self.run_time)
end

#reversed_resultsObject



82
# File 'lib/assert/suite.rb', line 82

def reversed_results;          end

#reversed_results_for_dumpObject



84
# File 'lib/assert/suite.rb', line 84

def reversed_results_for_dump; end

#reversed_testsObject



74
# File 'lib/assert/suite.rb', line 74

def reversed_tests;             end

#reversed_tests_by_run_timeObject



76
# File 'lib/assert/suite.rb', line 76

def reversed_tests_by_run_time; end

#run_timeObject



39
40
41
# File 'lib/assert/suite.rb', line 39

def run_time
  @end_time - @start_time
end

#setup(&block) ⇒ Object Also known as: startup



29
30
31
# File 'lib/assert/suite.rb', line 29

def setup(&block)
  self.setups << (block || proc{})
end

#suiteObject



27
# File 'lib/assert/suite.rb', line 27

def suite; self; end

#teardown(&block) ⇒ Object Also known as: shutdown



34
35
36
# File 'lib/assert/suite.rb', line 34

def teardown(&block)
  self.teardowns << (block || proc{})
end

#test_countObject



77
# File 'lib/assert/suite.rb', line 77

def test_count;                 end

#test_rateObject



43
44
45
# File 'lib/assert/suite.rb', line 43

def test_rate
  get_rate(self.test_count, self.run_time)
end