001 package org.junit.runner; 002 003 import org.junit.runner.notification.RunNotifier; 004 005 /** 006 * A <code>Runner</code> runs tests and notifies a {@link org.junit.runner.notification.RunNotifier} 007 * of significant events as it does so. You will need to subclass <code>Runner</code> 008 * when using {@link org.junit.runner.RunWith} to invoke a custom runner. When creating 009 * a custom runner, in addition to implementing the abstract methods here you must 010 * also provide a constructor that takes as an argument the {@link Class} containing 011 * the tests. 012 * 013 * <p>The default runner implementation guarantees that the instances of the test case 014 * class will be constructed immediately before running the test and that the runner 015 * will retain no reference to the test case instances, generally making them 016 * available for garbage collection. 017 * 018 * @see org.junit.runner.Description 019 * @see org.junit.runner.RunWith 020 * @since 4.0 021 */ 022 public abstract class Runner implements Describable { 023 /* 024 * (non-Javadoc) 025 * @see org.junit.runner.Describable#getDescription() 026 */ 027 public abstract Description getDescription(); 028 029 /** 030 * Run the tests for this runner. 031 * 032 * @param notifier will be notified of events while tests are being run--tests being 033 * started, finishing, and failing 034 */ 035 public abstract void run(RunNotifier notifier); 036 037 /** 038 * @return the number of tests to be run by the receiver 039 */ 040 public int testCount() { 041 return getDescription().testCount(); 042 } 043 }