TestSuite |
TestSuite (see Figure B-10) is a class representing a collection of Test s. Since it implements Test , it can be run just like a TestCase . When run, a TestSuite runs all the Test s it contains. It may contain both TestCase s and other TestSuite s.
A TestSuite can be constructed by giving it the class name of a TestCase . The TestSuite constructor uses reflection to find all methods in the TestCase having names starting with test . The code below adds all of BookTest 's test methods to a TestSuite and runs it:
TestSuite test = new TestSuite( BookTest.class ); test.run( new TestResult( ) );
Tests also can be added to a TestSuite using the addTest( ) method.
public class TestSuite extends Object implements Test
A constructor that creates an empty TestSuite .
A constructor that creates an empty TestSuite with the given name.
A constructor that takes a Class , uses reflection to find all methods with names starting with test , and adds them to the TestSuite as test methods.
A constructor that creates a TestSuite with the given name and all test methods found in the Class , as described for the previous constructor.
Adds a Test to the TestSuite .
Adds the test methods from the Class to the TestSuite . Test methods are found using reflection.
Returns the total number of test cases that will be run by this TestSuite . Test cases are counted by recursively calling countTestCases( ) for every Test in this TestSuite .
Creates an instance of Class as a Test with the given name.
Returns the name of the TestSuite .
Gets a constructor for the given Class that takes a single String as its argument, or gets a constructor that takes no arguments.
Runs the Test s in this TestSuite and collects the results in TestResult .
Runs Test and collects the results in TestResult .
Sets the name of the TestSuite .
Returns the Test at the given index.
Returns the number of Test s in this TestSuite .
Returns the Test s as an Enumeration .
Returns a string representation of this TestSuite .
A private method to add a test method to this TestSuite .
Returns the Throwable 's stack trace as a string.
Returns TRUE if Method has public access.
A private method that returns TRUE if Method has no arguments, returns void , and has public access.
Returns a Test that will fail and logs a warning message.
The name of this TestSuite .
The Test s contained by this TestSuite .