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