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.
protected var fPrinter:ResultPrinter
protected var result:TestResult
protected var startTime:Number
public function TestRunner()
protected function addedHandler(event:Event):void
Parameters
public function doRun(test:Test, showTrace:Boolean = false):TestResult
Parameters
| test:Test |
|
| showTrace:Boolean (default = false )
|
Returns
public function getPrinter():ResultPrinter
Returns
public function setPrinter(printer:ResultPrinter):void
Parameters
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
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);
public static const EXCEPTION_EXIT:int = 2
public static const FAILURE_EXIT:int = 1
public static const SHOW_TRACE:Boolean = true
public static const SUCCESS_EXIT:int = 0
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);
}
}
}