|
|||||||||
| Home >> All >> junit >> [ framework overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
junit.framework
Class TestSuite

java.lang.Objectjunit.framework.TestSuite
- All Implemented Interfaces:
- Test
- public class TestSuite
- extends java.lang.Object
- implements Test
- extends java.lang.Object
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.
| Field Summary | |
private java.lang.String |
fName
|
private java.util.Vector |
fTests
|
| Constructor Summary | |
TestSuite()
Constructs an empty TestSuite. |
|
TestSuite(java.lang.Class theClass)
Constructs a TestSuite from the given class. |
|
TestSuite(java.lang.Class theClass,
java.lang.String name)
Constructs a TestSuite from the given class with the given name. |
|
TestSuite(java.lang.String name)
Constructs an empty TestSuite. |
|
| Method Summary | |
void |
addTest(Test test)
Adds a test to the suite. |
private void |
addTestMethod(java.lang.reflect.Method m,
java.util.Vector names,
java.lang.Class theClass)
|
void |
addTestSuite(java.lang.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(java.lang.Class theClass,
java.lang.String name)
...as the moon sets over the early morning Merlin, Oregon mountains, our intrepid adventurers type... |
private static java.lang.String |
exceptionToString(java.lang.Throwable t)
Converts the stack trace into a string |
java.lang.String |
getName()
Returns the name of the suite. |
static java.lang.reflect.Constructor |
getTestConstructor(java.lang.Class theClass)
Gets a constructor which takes a single String as its argument or a no arg constructor. |
private boolean |
isPublicTestMethod(java.lang.reflect.Method m)
|
private boolean |
isTestMethod(java.lang.reflect.Method m)
|
void |
run(TestResult result)
Runs the tests and collects their result in a TestResult. |
void |
runTest(Test test,
TestResult result)
|
void |
setName(java.lang.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 |
java.util.Enumeration |
tests()
Returns the tests as an enumeration |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
private static Test |
warning(java.lang.String message)
Returns a test which will fail and log a warning message. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
fTests
private java.util.Vector fTests
fName
private java.lang.String fName
| Constructor Detail |
TestSuite
public TestSuite()
- Constructs an empty TestSuite.
TestSuite
public TestSuite(java.lang.Class theClass, java.lang.String name)
- Constructs a TestSuite from the given class with the given name.
TestSuite
public TestSuite(java.lang.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
TestSuite
public TestSuite(java.lang.String name)
- Constructs an empty TestSuite.
| Method Detail |
addTest
public void addTest(Test test)
- Adds a test to the suite.
addTestSuite
public void addTestSuite(java.lang.Class testClass)
- Adds the tests from the given class to the suite
addTestMethod
private void addTestMethod(java.lang.reflect.Method m, java.util.Vector names, java.lang.Class theClass)
createTest
public static Test createTest(java.lang.Class theClass, java.lang.String name)
- ...as the moon sets over the early morning Merlin, Oregon
mountains, our intrepid adventurers type...
exceptionToString
private static java.lang.String exceptionToString(java.lang.Throwable t)
- Converts the stack trace into a string
countTestCases
public int countTestCases()
- Counts the number of test cases that will be run by this test.
- Specified by:
countTestCasesin interfaceTest
getTestConstructor
public static java.lang.reflect.Constructor getTestConstructor(java.lang.Class theClass) throws java.lang.NoSuchMethodException
- Gets a constructor which takes a single String as
its argument or a no arg constructor.
isPublicTestMethod
private boolean isPublicTestMethod(java.lang.reflect.Method m)
isTestMethod
private boolean isTestMethod(java.lang.reflect.Method m)
run
public void run(TestResult result)
runTest
public void runTest(Test test, TestResult result)
testAt
public Test testAt(int index)
- Returns the test at the given index
testCount
public int testCount()
- Returns the number of tests in this suite
tests
public java.util.Enumeration tests()
- Returns the tests as an enumeration
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
setName
public void setName(java.lang.String name)
- Sets the name of the suite.
getName
public java.lang.String getName()
- Returns the name of the suite. Not all
test suites have a name and this method
can return null.
warning
private static Test warning(java.lang.String message)
- Returns a test which will fail and log a warning message.
|
|||||||||
| Home >> All >> junit >> [ framework overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
junit.framework.TestSuite