Class: TinyTest::Suite

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#testcaseObject (readonly)

Returns the value of attribute testcase.



192
193
194
# File 'lib/tinytest.rb', line 192

def testcase
  @testcase
end

#testnameObject (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

#executeObject

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

#inspectObject



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_countObject

To call by assertion methods calling.



261
262
263
# File 'lib/tinytest.rb', line 261

def succ_assertion_count
  @count_table[@state] += 1
end