Class Test::Unit::TestSuite
In: lib/test/unit/testsuite.rb
Parent: Object

A collection of tests which can be run.

Note: It is easy to confuse a TestSuite instance with something that has a static suite method; I know because I have trouble keeping them straight. Think of something that has a suite method as simply providing a way to get a meaningful TestSuite instance.

Methods

<<   ==   delete   empty?   new   run   size   to_s  

Constants

STARTED = name + "::STARTED"
FINISHED = name + "::FINISHED"

Attributes

name  [R] 
tests  [R] 

Public Class methods

Creates a new TestSuite with the given name.

[Source]

    # File lib/test/unit/testsuite.rb, line 24
24:       def initialize(name="Unnamed TestSuite")
25:         @name = name
26:         @tests = []
27:       end

Public Instance methods

Adds the test to the suite.

[Source]

    # File lib/test/unit/testsuite.rb, line 40
40:       def <<(test)
41:         @tests << test
42:         self
43:       end

It‘s handy to be able to compare TestSuite instances.

[Source]

    # File lib/test/unit/testsuite.rb, line 69
69:       def ==(other)
70:         return false unless(other.kind_of?(self.class))
71:         return false unless(@name == other.name)
72:         @tests == other.tests
73:       end

[Source]

    # File lib/test/unit/testsuite.rb, line 45
45:       def delete(test)
46:         @tests.delete(test)
47:       end

[Source]

    # File lib/test/unit/testsuite.rb, line 58
58:       def empty?
59:         tests.empty?
60:       end

Runs the tests and/or suites contained in this TestSuite.

[Source]

    # File lib/test/unit/testsuite.rb, line 31
31:       def run(result, &progress_block)
32:         yield(STARTED, name)
33:         @tests.each do |test|
34:           test.run(result, &progress_block)
35:         end
36:         yield(FINISHED, name)
37:       end

Retuns the rolled up number of tests in this suite; i.e. if the suite contains other suites, it counts the tests within those suites, not the suites themselves.

[Source]

    # File lib/test/unit/testsuite.rb, line 52
52:       def size
53:         total_size = 0
54:         @tests.each { |test| total_size += test.size }
55:         total_size
56:       end

Overridden to return the name given the suite at creation.

[Source]

    # File lib/test/unit/testsuite.rb, line 64
64:       def to_s
65:         @name
66:       end

[Validate]