Use the test suite method : Test Suite « JUnit « Java Tutorial






import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TestClassComposite extends TestCase {

  public TestClassComposite(String method) {
    super(method);
  }

  static public Test suite() {
    TestSuite suite = new TestSuite();
    
    suite.addTestSuite(TestClassOne.class);
    
    suite.addTest(TestClassTwo.suite());
    return suite;
  }

}

class TestClassOne extends TestCase {

  public TestClassOne(String method) {
    super(method);
  }

  public void testLongRunner() {
    assertEquals(2300, 50);
  }

}

class TestClassTwo extends TestCase {

  public TestClassTwo(String method) {
    super(method);
  }

  public void testLongRunner() {
    assertEquals(2300, 50);
  }

  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTest(new TestClassTwo("testLongRunner"));

    return suite;
  }
}








39.3.Test Suite
39.3.1.Test suite
39.3.2.Per-Suite Setup and Tear-Down
39.3.3.Define your own test case runner with reflection
39.3.4.Use the test suite method