|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.TestSuite
public class TestSuite
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);
Test
Constructor Summary | |
---|---|
TestSuite()
Constructs an empty TestSuite. |
|
TestSuite(Class<?>... classes)
Constructs a TestSuite from the given array of classes. |
|
TestSuite(Class<? extends TestCase> theClass)
Constructs a TestSuite from the given class. |
|
TestSuite(Class<? extends TestCase>[] classes,
String name)
Constructs a TestSuite from the given array of classes with the given name. |
|
TestSuite(Class<? extends TestCase> theClass,
String name)
Constructs a TestSuite from the given class with the given name. |
|
TestSuite(String name)
Constructs an empty TestSuite. |
Method Summary | |
---|---|
void |
addTest(Test test)
Adds a test to the suite. |
void |
addTestSuite(Class<? extends TestCase> 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<? extends TestCase> 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<? extends TestCase> |
getTestConstructor(Class<? extends TestCase> 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<Test> |
tests()
Returns the tests as an enumeration |
String |
toString()
|
static Test |
warning(String message)
Returns a test which will fail and log a warning message. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TestSuite()
public TestSuite(Class<? extends TestCase> theClass)
public TestSuite(Class<? extends TestCase> theClass, String name)
TestSuite(Class)
public TestSuite(String name)
public TestSuite(Class<?>... classes)
classes
- TestCase
spublic TestSuite(Class<? extends TestCase>[] classes, String name)
TestSuite(Class[])
Method Detail |
---|
public static Test createTest(Class<? extends TestCase> theClass, String name)
public static Constructor<? extends TestCase> getTestConstructor(Class<? extends TestCase> theClass) throws NoSuchMethodException
NoSuchMethodException
public static Test warning(String message)
public void addTest(Test test)
public void addTestSuite(Class<? extends TestCase> testClass)
public int countTestCases()
countTestCases
in interface Test
public String getName()
public void run(TestResult result)
run
in interface Test
public void runTest(Test test, TestResult result)
public void setName(String name)
name
- the name to setpublic Test testAt(int index)
public int testCount()
public Enumeration<Test> tests()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |