Packageflexunit.framework
Classpublic class TestCase
InheritanceTestCase Inheritance Assert
ImplementsTest
SubclassesEventfulTestCase, WarningTestCase

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


Public Properties
 PropertyDefined by
  assertionsMade : Number
TestCase
 InheritedassetionsMade : Number
[static]
Assert
  className : String
[read-only] Returns the the fully qualified class name
TestCase
 InheritedmaxAssertionsMade : Number
[static]
Assert
  methodName : String
The method name of the individual test to be run
TestCase
 InheritedtotalAssertionsMade : Number
[static]
Assert
Protected Properties
 PropertyDefined by
 Inherited_assertionsMade : Number = 0
[static]
Assert
Public Methods
 MethodDefined by
  
TestCase(methodName:String = null)
The TestCase constructor.
TestCase
  
addAsync(func:Function, timeout:int, passThroughData:Object = null, failFunc:Function = null):Function
Add an asynchronous check point to the test.
TestCase
 Inherited
assertContained(... rest):void
[static] Asserts that the first string is contained in the second one The first argument can be the message when the assertion fails
Assert
 Inherited
assertEquals(... rest):void
[static] Asserts that 2 values are equal.
Assert
 Inherited
assertFalse(... rest):void
[static] Asserts that a condition is false The first argument can be the message when the assertion fails
Assert
 Inherited
assertMatch(... rest):void
[static] Asserts that a string matches a regexp.
Assert
 Inherited
assertNoMatch(... rest):void
[static] Asserts that a string doesn't match a regexp.
Assert
 Inherited
assertNotContained(... rest):void
[static] Asserts that the first string is not contained in the second one The first argument can be the message when the assertion fails
Assert
 Inherited
assertNotNull(... rest):void
[static] Asserts that an object is not null The first argument can be the message when the assertion fails
Assert
 Inherited
assertNotUndefined(... rest):void
[static] Asserts that an object is not undefined The first argument can be the message when the assertion fails
Assert
 Inherited
assertNull(... rest):void
[static] Asserts that an object is null The first argument can be the message when the assertion fails
Assert
 Inherited
assertStrictlyEquals(... rest):void
[static] Asserts that two objects are strickly identical The first argument can be the message when the assertion fails
Assert
 Inherited
assertTrue(... rest):void
[static] Asserts that a condition is true The first argument can be the message when the assertion fails
Assert
 Inherited
assertUndefined(... rest):void
[static] Asserts that an object is undefined The first argument can be the message when the assertion fails
Assert
  
countTestCases():Number
The number of test cases in this test class.
TestCase
 Inherited
fail(failMessage:String = ""):void
[static] Fails with the given message
Assert
  
getNextAsync():Object
The AsyncTestHelper will call this when it's ready for to start the next async.
TestCase
  
TestCase
  
hasAsync():Boolean
Returns true if there are any asynchronous methods remaining to be called
TestCase
 Inherited
[static]
Assert
 Inherited
[static]
Assert
 Inherited
[static]
Assert
  
Creates a new TestResult and runs the tests, populating that TestResult with the results.
TestCase
  
runFinish():void
Runs tearDown()
TestCase
  
runMiddle():void
Runs the normal test method or the next asynchronous method
TestCase
  
runStart():void
Runs setUp()
TestCase
  
Runs the tests, populating the result parameter.
TestCase
  
Called by the TestResult to pass along so that it can be passed for async
TestCase
  
setUp():void
Empty implementation of setUp().
TestCase
  
startAsync():void
Called by the TestResult to kick off wait for the next asynchronous method
TestCase
  
tearDown():void
Empty implementation of tearDown().
TestCase
  
toString():String
A string representation of the test case
TestCase
Property detail
assertionsMadeproperty
assertionsMade:Number  [read-write]Implementation
    public function get assertionsMade():Number
    public function set assertionsMade(value:Number):void
classNameproperty 
className:String  [read-only]

Returns the the fully qualified class name

Implementation
    public function get className():String
methodNameproperty 
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()

runMiddle()method 
public function runMiddle():void

Runs the normal test method or the next asynchronous method

runStart()method 
public function runStart():void

Runs setUp()

runWithResult()method 
public function runWithResult(result:TestResult):void

Runs the tests, populating the result parameter.

Parameters
result:TestResult — TestResult instance to be populated
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
setUp()method 
public function setUp():void

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

startAsync()method 
public function startAsync():void

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

tearDown()method 
public function tearDown():void

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

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.