public class

TestSuite

extends Object
implements Test
java.lang.Object
   ↳ junit.framework.TestSuite
Known Direct Subclasses

Class Overview

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

Summary

Public Constructors
TestSuite()
Constructs an empty TestSuite.
TestSuite(Class theClass, String name)
Constructs a TestSuite from the given class with the given name.
TestSuite(Class theClass)
Constructs a TestSuite from the given class.
TestSuite(String name)
Constructs an empty TestSuite.
Public Methods
void addTest(Test test)
Adds a test to the suite.
void addTestSuite(Class testClass)
Adds the tests from the given class to the suite
int countTestCases()
Counts the number of test cases that will be run by this test.
static Test createTest(Class theClass, String name)
...as the moon sets over the early morning Merlin, Oregon mountains, our intrepid adventurers type...
String getName()
Returns the name of the suite.
static Constructor getTestConstructor(Class theClass)
Gets a constructor which takes a single String as its argument or a no arg constructor.
void run(TestResult result)
Runs the tests and collects their result in a TestResult.
void runTest(Test test, TestResult result)
void setName(String name)
Sets the name of the suite.
Test testAt(int index)
Returns the test at the given index
int testCount()
Returns the number of tests in this suite
Enumeration tests()
Returns the tests as an enumeration
String toString()
Returns a string containing a concise, human-readable description of this object.
[Expand]
Inherited Methods
From class java.lang.Object
From interface junit.framework.Test

Public Constructors

public TestSuite ()

Since: API Level 1

Constructs an empty TestSuite.

public TestSuite (Class theClass, String name)

Since: API Level 1

Constructs a TestSuite from the given class with the given name.

See Also

public TestSuite (Class theClass)

Since: API Level 1

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 Huffihutte, Kanton Uri

public TestSuite (String name)

Since: API Level 1

Constructs an empty TestSuite.

Public Methods

public void addTest (Test test)

Since: API Level 1

Adds a test to the suite.

public void addTestSuite (Class testClass)

Since: API Level 1

Adds the tests from the given class to the suite

public int countTestCases ()

Since: API Level 1

Counts the number of test cases that will be run by this test.

public static Test createTest (Class theClass, String name)

Since: API Level 1

...as the moon sets over the early morning Merlin, Oregon mountains, our intrepid adventurers type...

public String getName ()

Since: API Level 1

Returns the name of the suite. Not all test suites have a name and this method can return null.

public static Constructor getTestConstructor (Class theClass)

Since: API Level 1

Gets a constructor which takes a single String as its argument or a no arg constructor.

public void run (TestResult result)

Since: API Level 1

Runs the tests and collects their result in a TestResult.

public void runTest (Test test, TestResult result)

Since: API Level 1

public void setName (String name)

Since: API Level 1

Sets the name of the suite.

Parameters
name The name to set

public Test testAt (int index)

Since: API Level 1

Returns the test at the given index

public int testCount ()

Since: API Level 1

Returns the number of tests in this suite

public Enumeration tests ()

Since: API Level 1

Returns the tests as an enumeration

public String toString ()

Since: API Level 1

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.