API Documentation | All Packages | All Classes | Index | Frames No Frames |
FailOnTimeout

Package | org.flexunit.internals.runners.statements
Class | public class FailOnTimeout
Inheritance | FailOnTimeout AsyncStatementBase Object
Implements | IAsyncStatement

The `FailOnTimeout` is a decorator that is responsible for determing whether a specific test method has exceeded a timeout period for execution. A test method normally will run to completion regardless of how long it takes the test to execute; however, if a timeout is imposed on the test method, the test will fail if the test does not finish within the time limit. In order to fail on a timeout, a test method must include metadata indicating it has a timeout time limit. The timeout time limit is expected to be provided in milliseconds.

    	 [Test(timeout=100)]
    	 public function timeoutTest():void {
    	 	//Test to run
    	 }

Protected Properties
Hide Inherited Protected Properties
Show Inherited Protected Properties

| Property | Defined By
--- | --- | ---
|  | myToken : AsyncTestToken The AsyncTestToken for the current statment. | AsyncStatementBase
|  | parentToken : AsyncTestToken The AsyncTestToken for the parent of the current statment. | AsyncStatementBase

Public Methods

| Method | Defined By
--- | --- | ---
|  | FailOnTimeout(timeout:Number, statement:IAsyncStatement) Constructor. | FailOnTimeout
|  | evaluate(parentToken:AsyncTestToken):void Evaluates the object that implements the IAsyncStatement and starts the timeout timer. | FailOnTimeout
|  | handleNextExecuteComplete(result:ChildResult):void Stops the timer and sends any error the result has encountered to the parentToken. | FailOnTimeout
|  | hasTimeout(method:FrameworkMethod):String [static] Determine if the method test has a timeout by checking its metadata to see if it contains a "timeout" string. | FailOnTimeout

Protected Methods
Show Inherited Protected Methods
Show Inherited Protected Methods

| Method | Defined By
--- | --- | ---
|  | sendComplete(error:Error = null):void If the parentToken has not already been alerted that the statement has completed, alert the parent token that the current statement has finished. | AsyncStatementBase

Constructor Detail

FailOnTimeout | () | Constructor

`public function FailOnTimeout(timeout:Number, statement:IAsyncStatement)`

Constructor.

Parameters

| `timeout:Number` — The amount of time in milliseconds to wait before attempting to fail the test.
| `statement:IAsyncStatement` — The current object that implements `IAsyncStatement` to decorate.

Method Detail

evaluate | () | method

`public function evaluate(parentToken:AsyncTestToken):void`

Evaluates the object that implements the `IAsyncStatement` and starts the timeout timer.

Parameters

| `parentToken:AsyncTestToken` — The token to be notified when it has been determined if a timeout has occured.

handleNextExecuteComplete | () | method |

`public function handleNextExecuteComplete(result:ChildResult):void`

Stops the timer and sends any error the `result` has encountered to the parentToken. If the timer has already finished, the parentToken has been already notified of the failure and nothing further will occur.

Parameters

| `result:ChildResult` — The `ChildResult` to check to see if there is an error.

hasTimeout | () | method |

`public static function hasTimeout(method:FrameworkMethod):String`

Determine if the `method` test has a timeout by checking its metadata to see if it contains a "timeout" string.

Parameters

| `method:FrameworkMethod` — The `FrameworkMethod` to check to see if it has a timeout.

Returns

| `String` — a String indicating the length of the the timeout if the `method` contains metadata that indicates the method contains a timeout; otherwise, a value of `null` will be returned.

Thu Apr 10 2014, 08:07 AM +10:00