Class: TinyTest::Suite
- Inherits:
-
Object
- Object
- TinyTest::Suite
- Defined in:
- lib/tinytest.rb,
lib/tinytest/compat.rb
Overview
A unit of test executing.
Constant Summary collapse
- METHOD_ADDED_RECORDS =
{}
Instance Attribute Summary collapse
-
#testcase ⇒ Object
readonly
Returns the value of attribute testcase.
-
#testname ⇒ Object
readonly
Returns the value of attribute testname.
Instance Method Summary collapse
-
#assertion_count_grouping(&block) ⇒ Object
Bundle more than 1 assertion count to only 1.
-
#count_assertions(&block) ⇒ Object
Measure assertion count in block.
-
#execute ⇒ Object
Returns SuiteResult.
-
#initialize(testcase, testname) ⇒ Suite
constructor
A new instance of Suite.
- #inspect ⇒ Object
- #method_location(obj, name) ⇒ Object
-
#succ_assertion_count ⇒ Object
To call by assertion methods calling.
Constructor Details
#initialize(testcase, testname) ⇒ Suite
Returns a new instance of Suite.
184 185 186 187 188 189 190 |
# File 'lib/tinytest.rb', line 184 def initialize(testcase, testname) @testcase = testcase @testname = testname @testcase.bind_testsuite(self) @state = :base @count_table = { :base => 0, :counting => 0, :grouping => 0 } end |
Instance Attribute Details
#testcase ⇒ Object (readonly)
Returns the value of attribute testcase.
192 193 194 |
# File 'lib/tinytest.rb', line 192 def testcase @testcase end |
#testname ⇒ Object (readonly)
Returns the value of attribute testname.
193 194 195 |
# File 'lib/tinytest.rb', line 193 def testname @testname end |
Instance Method Details
#assertion_count_grouping(&block) ⇒ Object
Bundle more than 1 assertion count to only 1.
266 267 268 269 270 |
# File 'lib/tinytest.rb', line 266 def assertion_count_grouping(&block) state_shunting(:grouping, &block) ensure @count_table[:counting] += 1 unless @count_table[:grouping].zero? end |
#count_assertions(&block) ⇒ Object
Measure assertion count in block.
255 256 257 258 |
# File 'lib/tinytest.rb', line 255 def count_assertions(&block) state_shunting(:counting, &block) @count_table[:counting] end |
#execute ⇒ Object
Returns SuiteResult.
200 201 202 203 204 |
# File 'lib/tinytest.rb', line 200 def execute report = nil benchmark = Benchmark.measure{ report = execute_report() } SuiteResult.new(self, benchmark, report) end |
#inspect ⇒ Object
195 196 197 |
# File 'lib/tinytest.rb', line 195 def inspect "#{testcase.class}##{testname}" end |
#method_location(obj, name) ⇒ Object
234 235 236 |
# File 'lib/tinytest.rb', line 234 def method_location(obj, name) obj.method(name).source_location end |
#succ_assertion_count ⇒ Object
To call by assertion methods calling.
261 262 263 |
# File 'lib/tinytest.rb', line 261 def succ_assertion_count @count_table[@state] += 1 end |