// @(#)$Id: ConsoleTestRunner.scala,v 1.1 2005/10/28 09:04:50 leavens Exp leavens $
package testing;

import scala.testing.SUnit;
import SUnit._;

/** A Test Runner that writes on the Console.
 * @author Gary T. Leavens
 */
trait ConsoleTestRunner {

  /** Make the type TestSuite available, so clients
   *  don't have to import it themselves. */
  type TestSuite = SUnit.TestSuite; 

  /** The test suite (required). */
  val suite: TestSuite;

  /** The test result object to use. */
  def testRes: TestResult = new TestResult;

  /** Run the tests in the suite, 
   *  using testRes() to accumulate the results.
   */
  def main(args : Array[String]) : Unit = {
    val r = testRes;
    suite.run(r);
    if (r.failureCount() == 0) {
      Console.println("OK");
    } else {
      Console.println("" + r.failureCount() + " FAILURES!");
    }
    for(val tf <- r.failures()) {
      Console.println(tf.toString())
    }
  }
}
