TestRunner

public class
unittest.TestRunner

Description

TestRunner is the main entry point of the framework. It contains several static modular methods for better flexibility, while still providing a quick and easy way to run and report on all the tests of an Assembly (see runAll).

API overview

Constructor

TestRunner ()

Attributes

Public attributes

isRunning: Boolean static read-only

true if a test is currently running

onComplete: OnTestComplete static

Delegate that is called when all the tests are done

Functions

Public functions

getTests ( target: Object , createInstance: Boolean = true ): Vector.<Test> static

Scans the provided target and returns all the found tests

getTypeTests ( assembly: Assembly ): Vector.<TypeTest> static

Iterate over the provided assembly and retrieve all the types that contain tests in the form of TypeTests

report ( tests: Vector.<Test> , stackSkip: Number = 0 ): Void static

Output a detailed report on the tests

reportTypes ( typeTests: Vector.<TypeTest> , typeReport: StatusReport , testReport: StatusReport = null , assertReport: StatusReport = null ): Void static

Report on all the tests contained in the provided TypeTests

run ( tests: Vector.<Test> , shuffle: Boolean = true , complete: Function = null ): Void static

Run all the provided tests

runAll ( assembly: Assembly , shuffle: Boolean = true ): TestResult static

Run and report on all the tests in the specified assembly

runTypes ( typeTests: Vector.<TypeTest> , shuffle: Boolean = true , complete: Function = null ): Void static

Runs all the provided TypeTests and optionally updates the provided reports

Constructor

TestRunner ()

Attributes

isRunning: Boolean

static read-only

true if a test is currently running. Although asynchronous testing is supported, only one test suite can be run at a time. It is safe to run a test suite when this flag is false.

onComplete: OnTestComplete

static

Delegate that is called when all the tests are done.

Functions

getFullTypeName (): String
Inherited from Object

native

Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.


Returns

String fully qualified type name of the Object.

getTests ( target: Object , createInstance: Boolean = true ): Vector.<Test>

static

Scans the provided target and returns all the found tests. A test is a method marked with the [Test] metadata.

contains instance tests, create an instance of the type.

Parameters

target: Object It can be either an instance of a class or a Type object.
createInstance: Boolean = true If the provided target was not an instance and the type

Returns

Vector All the found test methods in the provided target.

getType (): Type
Inherited from Object

native

Gets the Type that describes the Object.


Returns

Type The Type that describes the object.

getTypeName (): String
Inherited from Object

native

Gets the type name of the Object.


Returns

String type name of the Object.

getTypeTests ( assembly: Assembly ): Vector.<TypeTest>

static

Iterate over the provided assembly and retrieve all the types that contain tests in the form of TypeTests.

Parameters

assembly: Assembly The assembly to iterate over.

Returns

Vector A Vector of TypeTests for each type containing at least one test.

report ( tests: Vector.<Test> , stackSkip: Number = 0 ): Void

static

Output a detailed report on the tests. It is assumed that the tests have already been ran.

Parameters

tests: Vector.<Test> The tests to report on.
stackSkip: Number = 0 The number of calls to skip from the bottom of the call stack.


reportTypes ( typeTests: Vector.<TypeTest> , typeReport: StatusReport , testReport: StatusReport = null , assertReport: StatusReport = null ): Void

static

Report on all the tests contained in the provided TypeTests.

Parameters

typeTests: Vector.<TypeTest> The TypeTests to report on.
typeReport: StatusReport The status report containing the results of the run.
testReport: StatusReport = null Optional status report on tests.
assertReport: StatusReport = null Optional status report on assertions.


run ( tests: Vector.<Test> , shuffle: Boolean = true , complete: Function = null ): Void

static

Run all the provided tests. The tests are updated with the results.

Parameters

tests: Vector.<Test> The tests to run.
shuffle: Boolean = true If true, shuffle the tests to fail fast for tests that depend on side effects and specific execution order.
complete: Function = null Function that will be called when the operation is complete


runAll ( assembly: Assembly , shuffle: Boolean = true ): TestResult

static

Run and report on all the tests in the specified assembly.

Synchronous and asychronous tests are supported. In order to run a test asynchronously, simply give your test function a parameter of the type unittest.TestComplete and then call the .done() function when the test is finished. See TestComplete for more details.

All tests, synchronous and asynchronous are marked by the [Test] metadata.

Use Type.getAssembly() or getType().getAssembly() for an easy way to run tests in the currently running application.

true to allow for faster failure of tests that depend on side effects.

accumulated results.

Parameters

assembly: Assembly The assembly from which to run the tests.
shuffle: Boolean = true Whether to shuffle the tests or not, defaults to

Returns

TestResult A TestResult containing the run TypeTests and their

runTypes ( typeTests: Vector.<TypeTest> , shuffle: Boolean = true , complete: Function = null ): Void

static

Runs all the provided TypeTests and optionally updates the provided reports.

Parameters

typeTests: Vector.<TypeTest> The TypeTests to run.
shuffle: Boolean = true If true, shuffles the types first.
complete: Function = null


toString (): String
Inherited from Object

native

Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().


Returns

String String that described the Object.

: