1b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpackage org.junit.runner; 2b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 3b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.junit.runner.notification.RunNotifier; 4b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 5b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot/** 6b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * A <code>Runner</code> runs tests and notifies a {@link org.junit.runner.notification.RunNotifier} 7b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * of significant events as it does so. You will need to subclass <code>Runner</code> 8b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * when using {@link org.junit.runner.RunWith} to invoke a custom runner. When creating 9b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * a custom runner, in addition to implementing the abstract methods here you must 10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * also provide a constructor that takes as an argument the {@link Class} containing 11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * the tests. 12b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <p/> 13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * The default runner implementation guarantees that the instances of the test case 14b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * class will be constructed immediately before running the test and that the runner 15b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * will retain no reference to the test case instances, generally making them 16b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * available for garbage collection. 17b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * 18b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.runner.Description 19b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.runner.RunWith 20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 21b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic abstract class Runner implements Describable { 22b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /* (non-Javadoc) 23b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.runner.Describable#getDescription() 24b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 25b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public abstract Description getDescription(); 26b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 27b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 28b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Run the tests for this runner. 29b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param notifier will be notified of events while tests are being run--tests being 30b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * started, finishing, and failing 31b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 32b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public abstract void run(RunNotifier notifier); 33b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 34b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 35b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return the number of tests to be run by the receiver 36b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 37b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public int testCount() { 38b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return getDescription().testCount(); 39b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 40b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot}