Packageasunit.textui
Classpublic class TestRunner
InheritanceTestRunner Inheritance flash.display.Sprite

The base class for ActionScript 3.0 test harness. The TestRunner should be extended by your concrete runner for your project. If you're building a Flex application, you will need to extend the FlexRunner Your concrete runner will usually look like the following:
      package {
          import asunit.textui.TestRunner;
      
          public class MyProjectRunner extends TestRunner {
          
              public function MyProjectRunner() {
                  // start(clazz:Class, methodName:String, showTrace:Boolean)
                  // NOTE: sending a particular class and method name will
                  // execute setUp(), the method and NOT tearDown.
                  // This allows you to get visual confirmation while developing
                  // visual entities
                  start(AllTests, null, TestRunner.SHOW_TRACE);
              }
          }
      }
      

View the examples.

See also

asunit.textui.FlexRunner
asunit.textui.AirRunner
asunit.textui.XMLResultPrinter


Protected Properties
 PropertyDefined by
  fPrinter : ResultPrinter
TestRunner
  result : TestResult
TestRunner
  startTime : Number
TestRunner
Public Methods
 MethodDefined by
  
TestRunner
  
doRun(test:Test, showTrace:Boolean = false):TestResult
TestRunner
  
TestRunner
  
setPrinter(printer:ResultPrinter):void
TestRunner
  
start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult
Starts a test run based on the TestCase or TestSuite provided.
TestRunner
Protected Methods
 MethodDefined by
  
addedHandler(event:Event):void
TestRunner
Public Constants
 ConstantDefined by
  EXCEPTION_EXIT : int = 2
[static]
TestRunner
  FAILURE_EXIT : int = 1
[static]
TestRunner
  SHOW_TRACE : Boolean = true
[static]
TestRunner
  SUCCESS_EXIT : int = 0
[static]
TestRunner
Property detail
fPrinterproperty
protected var fPrinter:ResultPrinter
resultproperty 
protected var result:TestResult
startTimeproperty 
protected var startTime:Number
Constructor detail
TestRunner()constructor
public function TestRunner()
Method detail
addedHandler()method
protected function addedHandler(event:Event):voidParameters
event:Event
doRun()method 
public function doRun(test:Test, showTrace:Boolean = false):TestResultParameters
test:Test
 
showTrace:Boolean (default = false)

Returns
TestResult
getPrinter()method 
public function getPrinter():ResultPrinter

Returns
ResultPrinter
setPrinter()method 
public function setPrinter(printer:ResultPrinter):voidParameters
printer:ResultPrinter
start()method 
public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult

Starts a test run based on the TestCase or TestSuite provided. If a concrete TestCase is provided to the start method, you can also provide the string name of a single test method to execute. This will run the TestCase setUp method, then the test method name that was provided, and will not run tearDown. This is a great way to build visual components in isolation and verify that they behave as expected.

Parameters
testCase:Class
 
testMethod:String (default = null)
 
showTrace:Boolean (default = false)

Returns
TestResult

See also

TestSuite

Example
The start method can accept a concrete test case and test method name:
          start(MyTestCase, 'myTestMethod');
          

The start method usually accepts a test suite that includes all of your test methods.
          start(AllTests, null, TestRunner.SHOW_TRACE);
          

Constant detail
EXCEPTION_EXITconstant
public static const EXCEPTION_EXIT:int = 2
FAILURE_EXITconstant 
public static const FAILURE_EXIT:int = 1
SHOW_TRACEconstant 
public static const SHOW_TRACE:Boolean = true
SUCCESS_EXITconstant 
public static const SUCCESS_EXIT:int = 0
Examples

package {
    import asunit.textui.TestRunner;
    
    public class SomeProjectRunner extends TestRunner {

        public function SomeProjectRunner() {
            // start(clazz:Class, methodName:String, showTrace:Boolean)
            // NOTE: sending a particular class and method name will
            // execute setUp(), the method and NOT tearDown.
            // This allows you to get visual confirmation while developing
            // visual entities
            start(AllTests, null, TestRunner.SHOW_TRACE);
        }
    }
}