momeunit.framework
Class TestSuite

java.lang.Object
  extended by momeunit.framework.TestSuite
All Implemented Interfaces:
Test

public class TestSuite
extends Object
implements Test

A collection of tests that can be processed together. TestSuite has a name property that identifies it. It can be returned or modified using property methods It can be also preset during instantiation using TestSuite(String),TestSuite(String, Class[]) or TestSuite(String, String[]) constructors. A test can be added to TestSuite by calling addTest(Class) or addTest(String) method with class or name of class implementing Test interface. A test can also be added to TestSuite by calling addTest(Test) method with test instance. The collection of tests can be preset during instantiation by using a constructors TestSuite(Class[]), TestSuite(String[]), TestSuite(String, Class[]) or TestSuite(String, String[]). The arguments to these constructors are optional name of test suite and array of classes or names of classes implementing Test interface. To run tests that constitute this TestSuite call run(TestResult). To run some test call runTest(Test, TestResult) method. There are also getter methods that return number of tests in test suite, number of TestCases in test suite (test suite can also contain other test suites or any other Test implementations), test at specified position.

Version:
1.1.2
Author:
Sergio Morozov
See Also:
Test, TestSuite.ErrorTestCase

Nested Class Summary
(package private)  class TestSuite.ErrorTestCase
          Returns the name of the suite.
 
Constructor Summary
TestSuite()
          Constructs an empty TestSuite.
TestSuite(Class[] classes)
          Constructs a TestSuite with default name consisting of tests specified as classes.
TestSuite(String name)
          Constructs an empty TestSuite with specified name.
TestSuite(String[] classes)
          Constructs a TestSuite with default name consisting of tests specified as classnames.
TestSuite(String name, Class[] classes)
          Constructs a TestSuite with the given name consisting of tests specified as classes.
TestSuite(String name, String[] classes)
          Constructs a TestSuite with the given name consisting of tests specified as classnames.
 
Method Summary
 void addTest(Class testClass)
          Adds test specified by class implementing Test to the test suite.
 void addTest(String className)
          Adds test specified by name of class implementing Test to the test suite.
 void addTest(Test test)
          Adds specified test to the test suite.
 int countTestCases()
          Counts the number of test cases that will be run by this test.
 String getName()
          Returns the name of the test suite.
 void run(TestResult result)
          Runs tests of this test suite and collects results in a TestResult instance.
 void runTest(Test test, TestResult result)
          Runs the specified test and populates the specified TestResult with results of test.
 void setName(String name)
          Sets the name of test suite to the specified or default, if name is null .
 Test testAt(int index)
          Returns the test at the given index.
 int testCount()
          Returns the number of tests that constitute test suite.
 Enumeration tests()
          Returns enumeration of tests that constitute test suite.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestSuite

public TestSuite()
Constructs an empty TestSuite.

Since:
1.0

TestSuite

public TestSuite(String name)
Constructs an empty TestSuite with specified name.

Parameters:
name - the name of test suite.
Since:
1.0

TestSuite

public TestSuite(Class[] classes)
Constructs a TestSuite with default name consisting of tests specified as classes.

Parameters:
classes - array of classes implementing Test interface.
Since:
1.0

TestSuite

public TestSuite(String[] classes)
Constructs a TestSuite with default name consisting of tests specified as classnames.

Parameters:
classes - array of names of classes implementing Test interface.
Since:
1.0

TestSuite

public TestSuite(String name,
                 Class[] classes)
Constructs a TestSuite with the given name consisting of tests specified as classes.

Parameters:
name - the name of test suite.
classes - array of classes implementing Test interface.
Since:
1.0

TestSuite

public TestSuite(String name,
                 String[] classes)
Constructs a TestSuite with the given name consisting of tests specified as classnames.

Parameters:
name - the name of test suite.
classes - array of names of classes implementing Test interface.
Since:
1.0
Method Detail

getName

public String getName()
Returns the name of the test suite.

Returns:
name of test suite.
Since:
1.0

setName

public void setName(String name)
Sets the name of test suite to the specified or default, if name is null .

Parameters:
name - name of test suite or null.
Since:
1.0

addTest

public void addTest(Test test)
Adds specified test to the test suite.

Parameters:
test - test to be added to the test suite.
Since:
1.0

addTest

public void addTest(Class testClass)
Adds test specified by class implementing Test to the test suite.

Parameters:
testClass - class implementing Test to be added to the test suite.
Since:
1.0

addTest

public void addTest(String className)
Adds test specified by name of class implementing Test to the test suite.

Parameters:
className - name of class implementing Test to be added to the test suite.
Since:
1.0

countTestCases

public int countTestCases()
Description copied from interface: Test
Counts the number of test cases that will be run by this test.

Specified by:
countTestCases in interface Test

run

public void run(TestResult result)
Runs tests of this test suite and collects results in a TestResult instance.

Specified by:
run in interface Test
Since:
1.0
See Also:
Test.run(momeunit.framework.TestResult)

runTest

public void runTest(Test test,
                    TestResult result)
Runs the specified test and populates the specified TestResult with results of test.

Parameters:
test - test to be run.
result - TestResult instance to be populated with results of the test.
Since:
1.0

testAt

public Test testAt(int index)
Returns the test at the given index.

Parameters:
index - index of the test to be returned.
Returns:
test at the specified index.
Since:
1.0

testCount

public int testCount()
Returns the number of tests that constitute test suite.

Returns:
number of tests that constitute test suite.
Since:
1.0

tests

public Enumeration tests()
Returns enumeration of tests that constitute test suite.

Returns:
enumeration of tests.
Since:
1.0

toString

public String toString()
Overrides:
toString in class Object
Since:
1.0