If you have two tests and you'll run them together you
could run the tests one at a time yourself, but you would quickly grow tired of
that.
Instead, JUnit provides an object TestSuite which runs any number
of test cases together. The suite method is like a main method that is
specialized to run tests.
Create a suite and add each test case you want to
execute:
public static void suite(){
TestSuite suite = new TestSuite();
suite.addTest(new BookTest("testEquals"));
suite.addTest(new BookTest("testBookAdd"));
return suite;
}
Since JUnit 2.0 there is an even simpler way to create
a test suite, which holds all testXXX() methods. You only pass the class with
the tests to a TestSuite and it extracts the test methods automatically.
Note: If you use this way to create a TestSuite all
test methods will be added. If you do not want all test methods in the TestSuite
use the normal way to create it.
Example:
public static void suite(){
return new TestSuite(BookTest.class);
}