Class: Test::Unit::TestSuite

Class | Test::Unit::TestSuite
In: | 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

new(name="Unnamed TestSuite")

Creates a new TestSuite with the given name.

[Source]

    # File test/unit/testsuite.rb, line 22
          def initialize(name="Unnamed TestSuite")
            @name = name
            @tests = []
          end

### Public Instance methods

<<(test)

Adds the test to the suite.

[Source]

    # File test/unit/testsuite.rb, line 38
          def <<(test)
            @tests << test
            self
          end

==(other)

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

[Source]

    # File test/unit/testsuite.rb, line 67
          def ==(other)
            return false unless(other.kind_of?(self.class))
            return false unless(@name == other.name)
            @tests == other.tests
          end

delete(test)

[Source]

    # File test/unit/testsuite.rb, line 43
          def delete(test)
            @tests.delete(test)
          end

empty?()

[Source]

    # File test/unit/testsuite.rb, line 56
          def empty?
            tests.empty?
          end

run(result) {|STARTED, name| ...}

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

[Source]

    # File test/unit/testsuite.rb, line 29
          def run(result, &progress_block)
            yield(STARTED, name)
            @tests.each do |test|
              test.run(result, &progress_block)
            end
            yield(FINISHED, name)
          end

size()

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 test/unit/testsuite.rb, line 50
          def size
            total_size = 0
            @tests.each { |test| total_size += test.size }
            total_size
          end

to_s()

Overridden to return the name given the suite at creation.

[Source]

    # File test/unit/testsuite.rb, line 62
          def to_s
            @name
          end

[Validate]