flexunit.framework

Class TestCase

flexunit.framework.Assert

All implemented interfaces
Test
Direct known subclasses
WarningTestCase

public class TestCase
extends Assert

The Base Class for test cases. A Test case defines the fixture in which to run multiple tests.

See also
flexunit.flexui.TestRunner, Assert, TestSuite, TestResult



Property Summary
className:String  [read-only]
Returns the the fully qualified class name
methodName:String
The method name of the individual test to be run


Constructor Summary
TestCase(methodName:String = null)
The TestCase constructor.


Method Summary
addAsync(func:Function, timeout:int, passThroughData:Object = null, failFunc:Function = null) : Function
Add an asynchronous check point to the test.
countTestCases() : Number
The number of test cases in this test class.
getNextAsync() : Object
The AsyncTestHelper will call this when it's ready for to start the next async.
getTestMethodNames() : Array
hasAsync() : Boolean
Returns true if there are any asynchronous methods remaining to be called
run() : TestResult
Creates a new TestResult and runs the tests, populating that TestResult with the results.
runFinish() : void
Runs tearDown()
runMiddle() : void
Runs the normal test method or the next asynchronous method
runStart() : void
Runs setUp()
runWithResult(result:TestResult) : void
Runs the tests, populating the result parameter.
setTestResult(result:TestResult) : void
Called by the TestResult to pass along so that it can be passed for async
setUp() : void
Empty implementation of setUp().
startAsync() : void
Called by the TestResult to kick off wait for the next asynchronous method
tearDown() : void
Empty implementation of tearDown().
toString() : String
A string representation of the test case


Property Detail

className Property

Usage
    className:String

Implementation
    public function get className() : String

Returns the the fully qualified class name

methodName Property

public var methodName:String

The method name of the individual test to be run

Constructor Detail

TestCase Constructor

public function TestCase(methodName:String = null)

The TestCase constructor. If you provide a contstructor in a TestCase subclass, you should ensure that this constructor is called.

Parameters
methodName:String (default = null) — name of the test method to be called in the test run.


Method Detail

addAsync Method

public function addAsync(func:Function, timeout:int, passThroughData:Object = null, failFunc:Function = null) : Function

Add an asynchronous check point to the test. This method will return an event handler function.

Parameters
func:Function — the Function to execute when things have been handled
timeout:int — if the function isn't called within this time the test is considered a failure
passThroughData:Object (default = null) — data that will be passed to your function (only if non-null) as the 2nd argument
failFunc:Function (default = null) — a Function that will be called if the asynchronous function fails to execute, useful if perhaps the failure to execute was intentional or if you want a specific failure message

Returns
Function — the Function that can be used as an event listener

countTestCases Method

public function countTestCases() : Number

The number of test cases in this test class.

Returns
Number — A Number representation the count of test cases in this test class. Always returns 1 for TestCase

getNextAsync Method

public function getNextAsync() : Object

The AsyncTestHelper will call this when it's ready for to start the next async. It's possible that it will need to get access to it even before async has been started if the call didn't actually end up being asynchronous.

Returns
Object

getTestMethodNames Method

public function getTestMethodNames() : Array

Returns
Array

hasAsync Method

public function hasAsync() : Boolean

Returns true if there are any asynchronous methods remaining to be called

Returns
Boolean

run Method

public function run() : TestResult

Creates a new TestResult and runs the tests, populating that TestResult with the results.

Returns
TestResult

runFinish Method

public function runFinish() : void

Runs tearDown()

Returns
void

runMiddle Method

public function runMiddle() : void

Runs the normal test method or the next asynchronous method

Returns
void

runStart Method

public function runStart() : void

Runs setUp()

Returns
void

runWithResult Method

public function runWithResult(result:TestResult) : void

Runs the tests, populating the result parameter.

Parameters
result:TestResult — TestResult instance to be populated

Returns
void

setTestResult Method

public function setTestResult(result:TestResult) : void

Called by the TestResult to pass along so that it can be passed for async

Parameters
result:TestResult

Returns
void

setUp Method

public function setUp() : void

Empty implementation of setUp(). Can be overridden in test class.

Returns
void

startAsync Method

public function startAsync() : void

Called by the TestResult to kick off wait for the next asynchronous method

Returns
void

tearDown Method

public function tearDown() : void

Empty implementation of tearDown(). Can be overridden in test class.

Returns
void

toString Method

public function toString() : String

A string representation of the test case

Returns
String — A string representation of the test class name and the test method name.