junit.framework
Class TestSuite

java.lang.Object
  |
  +--junit.framework.TestSuite

public class TestSuite
extends java.lang.Object
implements Test

A TestSuite is a Composite of Tests. It runs a collection of test cases. Here is an example using the dynamic test definition.

 TestSuite suite= new TestSuite();
 suite.addTest(new MathTest("testAdd"));
 suite.addTest(new MathTest("testDivideByZero"));
 
Alternatively, a TestSuite can extract the tests to be run automatically. To do so you pass the class of your TestCase class to the TestSuite constructor.
 TestSuite suite= new TestSuite(MathTest.class);
 
This constructor creates a suite with all the methods starting with "test" that take no arguments.

See Also:
Test

Constructor Summary
TestSuite()
          Constructs an empty TestSuite.
TestSuite(java.lang.Class theClass)
          Constructs a TestSuite from the given class.
TestSuite(java.lang.String name)
          Constructs an empty TestSuite.
 
Method Summary
 void addTest(Test test)
          Adds a test to the suite.
 int countTestCases()
          Counts the number of test cases that will be run by this test.
 void run(TestResult result)
          Runs the tests and collects their result in a TestResult.
 Test testAt(int index)
          Returns the test at the given index
 int testCount()
          Returns the number of tests in this suite
 java.util.Enumeration tests()
          Returns the tests as an enumeration
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestSuite

public TestSuite()
Constructs an empty TestSuite.

TestSuite

public TestSuite(java.lang.Class theClass)
Constructs a TestSuite from the given class. Adds all the methods starting with "test" as test cases to the suite. Parts of this method was written at 2337 meters in the H?ffih?tte, Kanton Uri

TestSuite

public TestSuite(java.lang.String name)
Constructs an empty TestSuite.
Method Detail

addTest

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

countTestCases

public int countTestCases()
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 the tests and collects their result in a TestResult.
Specified by:
run in interface Test

testAt

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

testCount

public int testCount()
Returns the number of tests in this suite

tests

public java.util.Enumeration tests()
Returns the tests as an enumeration

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object