2003-02-11 22:12:14 -05:00
|
|
|
# :nodoc:
|
|
|
|
#
|
|
|
|
# Author:: Nathaniel Talbott.
|
2003-08-06 10:03:21 -04:00
|
|
|
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
2003-02-11 22:12:14 -05:00
|
|
|
# License:: Ruby license.
|
|
|
|
|
|
|
|
module Test
|
|
|
|
module Unit
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
class TestSuite
|
|
|
|
attr_reader :name, :tests
|
|
|
|
|
|
|
|
STARTED = name + "::STARTED"
|
|
|
|
FINISHED = name + "::FINISHED"
|
|
|
|
|
|
|
|
# Creates a new TestSuite with the given name.
|
|
|
|
def initialize(name="Unnamed TestSuite")
|
|
|
|
@name = name
|
|
|
|
@tests = []
|
|
|
|
end
|
|
|
|
|
|
|
|
# Runs the tests and/or suites contained in this
|
|
|
|
# TestSuite.
|
|
|
|
def run(result, &progress_block)
|
|
|
|
yield(STARTED, name)
|
2003-10-01 22:20:42 -04:00
|
|
|
@tests.each do |test|
|
2003-02-11 22:12:14 -05:00
|
|
|
test.run(result, &progress_block)
|
|
|
|
end
|
|
|
|
yield(FINISHED, name)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Adds the test to the suite.
|
|
|
|
def <<(test)
|
|
|
|
@tests << test
|
2003-10-03 18:35:19 -04:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete(test)
|
|
|
|
@tests.delete(test)
|
2003-02-11 22:12:14 -05:00
|
|
|
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.
|
|
|
|
def size
|
|
|
|
total_size = 0
|
|
|
|
@tests.each { |test| total_size += test.size }
|
|
|
|
total_size
|
|
|
|
end
|
|
|
|
|
|
|
|
def empty?
|
|
|
|
tests.empty?
|
|
|
|
end
|
|
|
|
|
* dln.c, io.c, pack.c, lib/benchmark.rb, lib/cgi.rb, lib/csv.rb,
lib/date.rb, lib/ftools.rb, lib/getoptlong.rb, lib/logger.rb,
lib/matrix.rb, lib/monitor.rb, lib/set.rb, lib/thwait.rb,
lib/timeout.rb, lib/yaml.rb, lib/drb/drb.rb, lib/irb/workspace.rb,
lib/net/ftp.rb, lib/net/http.rb, lib/net/imap.rb, lib/net/pop.rb,
lib/net/telnet.rb, lib/racc/parser.rb, lib/rinda/rinda.rb,
lib/rinda/tuplespace.rb, lib/shell/command-processor.rb,
lib/soap/rpc/soaplet.rb, lib/test/unit/testcase.rb,
lib/test/unit/testsuite.rb: typo fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-04-18 19:19:47 -04:00
|
|
|
# Overridden to return the name given the suite at
|
2003-02-11 22:12:14 -05:00
|
|
|
# creation.
|
|
|
|
def to_s
|
|
|
|
@name
|
|
|
|
end
|
2003-08-06 10:03:21 -04:00
|
|
|
|
|
|
|
# It's handy to be able to compare TestSuite instances.
|
|
|
|
def ==(other)
|
|
|
|
return false unless(other.kind_of?(self.class))
|
|
|
|
return false unless(@name == other.name)
|
|
|
|
@tests == other.tests
|
|
|
|
end
|
2003-02-11 22:12:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|