⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
junit.framework

Class TestSuite

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

All Implemented Interfaces:
Test

Known Direct Subclasses:
ActiveTestSuite


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(Class theClass, String name)

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

TestSuite(final Class theClass)

Constructs a TestSuite from the given class.

TestSuite(String name)

Constructs an empty TestSuite.

Method Summary

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()

Constructor Details

TestSuite

public TestSuite()

Constructs an empty TestSuite.


TestSuite

public TestSuite(Class theClass, String name)

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

Parameters:
theClass
name
See Also:
TestSuite.TestSuite(Class)

TestSuite

public TestSuite(String name)

Constructs an empty TestSuite.

Parameters:
name

TestSuite

public TestSuite(final 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

Parameters:
theClass

Method Details

addTest

public void addTest(Test test)

Adds a test to the suite.

Parameters:
test

addTestSuite

public void addTestSuite(Class testClass)

Adds the tests from the given class to the suite

Parameters:
testClass

countTestCases

public int countTestCases()

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


createTest

public static Test createTest(Class theClass, String name)

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

Parameters:
theClass
name

getName

public String getName()

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


getTestConstructor

public static Constructor getTestConstructor(Class theClass)

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

Parameters:
theClass

run

public void run(TestResult result)

Runs the tests and collects their result in a TestResult.

Parameters:
result

runTest

public void runTest(Test test, TestResult result)

Parameters:
test
result

setName

public void setName(String name)

Sets the name of the suite.

Parameters:
name - The name to set

testAt

public Test testAt(int index)

Returns the test at the given index

Parameters:
index

testCount

public int testCount()

Returns the number of tests in this suite


tests

public Enumeration tests()

Returns the tests as an enumeration


toString

public String toString()