com.gargoylesoftware.base.testing
public final class OrderedTestSuite extends TestSuite
Generally, when you want to specify the order that tests will be run, you write code that looks like this.
public static Test suite() { final TestSuite suite = new TestSuite(); suite.addTest( new FooTest("testOne") ); suite.addTest( new FooTest("testTwo") ); return suite; }The problem with this approach is that when testThree() is written, if it isn't added to the suite method, it won't get executed.
Using OrderedTestSuite, you write code like this:
public static Test suite() { return new OrderedTestSuite(FooTest.class, new String[]{"testOne", "testTwo"}); }testOne() and testTwo() will be executed in order just as in the first example. The difference is that OrderedTestSuite will use reflection to find other methods starting with test and will execute them. This means that if you write testThree but forget to add it to suite() then it will still get executed, albeit not in a defined order.
Version: $Revision: 1.3 $
Field Summary | |
---|---|
Class | classToTest_ |
String[] | orderedMethodNames_ |
Constructor Summary | |
---|---|
OrderedTestSuite(Class clazz, String[] methodNames)
Create an instance of this test suite
|
Method Summary | |
---|---|
void | addMethodsInOrder(Map methodMap) |
void | addTest(Method method) |
Map | getMatchingMethods() |
boolean | isMatchingMethod(Method method) |
Parameters: clazz the class that we will use to get the individual tests. This must be a subclass of TestCase methodNames The names of any methods that must be tested in order