java.lang.Object | |
↳ | junit.framework.TestSuite |
Known Direct Subclasses |
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.
A final option is to do the same for a large array of test classes.
Class[] testClasses = { MathTest.class, AnotherTest.class } TestSuite suite= new TestSuite(testClasses);
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs an empty TestSuite.
| |||||||||||
Constructs a TestSuite from the given class.
| |||||||||||
Constructs a TestSuite from the given class with the given name.
| |||||||||||
Constructs an empty TestSuite.
| |||||||||||
Constructs a TestSuite from the given array of classes.
| |||||||||||
Constructs a TestSuite from the given array of classes with the given name.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a test to the suite.
| |||||||||||
Adds the tests from the given class to the suite
| |||||||||||
Counts the number of test cases that will be run by this test.
| |||||||||||
...as the moon sets over the early morning Merlin, Oregon
mountains, our intrepid adventurers type...
| |||||||||||
Returns the name of the suite.
| |||||||||||
Gets a constructor which takes a single String as
its argument or a no arg constructor.
| |||||||||||
Runs the tests and collects their result in a TestResult.
| |||||||||||
Sets the name of the suite.
| |||||||||||
Returns the test at the given index
| |||||||||||
Returns the number of tests in this suite
| |||||||||||
Returns the tests as an enumeration
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Returns a test which will fail and log a warning message.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
junit.framework.Test
|
Constructs a TestSuite from the given class. Adds all the methods starting with "test" as test cases to the suite. Parts of this method were written at 2337 meters in the Hueffihuette, Kanton Uri
Constructs a TestSuite from the given class with the given name.
Constructs a TestSuite from the given array of classes.
classes | TestCase s
|
---|
Constructs a TestSuite from the given array of classes with the given name.
Adds the tests from the given class to the suite
Counts the number of test cases that will be run by this test.
...as the moon sets over the early morning Merlin, Oregon mountains, our intrepid adventurers type...
Returns the name of the suite. Not all test suites have a name and this method can return null.
Gets a constructor which takes a single String as its argument or a no arg constructor.
NoSuchMethodException |
---|
Runs the tests and collects their result in a TestResult.
Sets the name of the suite.
name | the name to set |
---|
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 test which will fail and log a warning message.