Class org.as2lib.test.unit.TestCase

org.as2lib.core.BasicClass
   +--org.as2lib.test.unit.TestCase

Implemented Interfaces

Test

Description

Testcase class to be extended.

A Testcase defines the Access to all parts of the TestUnit System of as2lib. It is handled as an abstract class this means you have to extend it if you want to work with the system (similar to the most other testunit systems). import org.as2lib.test.unit.TestCase; class MyTestCase extends TestCase { } A testcase usually gets processed by run. The System will fetch all Methods starting with "test" and execute them in a new, isolated instance. Before each method call the methods setUp and tearDown will get called. Example: Testcase: import org.as2lib.test.unit.TestCase; class MyTestCase extends TestCase { public function TestCase(Void) { trace('new instance'); } public function setUp(Void){ trace('set up'); } public function testMyFirstTest(Void) { trace('myFirstTest'); } public function testMySecondTest(Void) { trace('mySecondTest'); } public function tearDown(Void){ trace('tear down'); } } Call: new MyTestCase().run(); Result: new instance set up myFirstTest tear down new instance set up mySecondTest tear down Within the "test"-methods you have access to different assert methods:

Methodname Checks
assertTrue value === true
assertFalse value === false
assertEquals a == b
assertAlmostEquals (a < b && a+x > b) || (a > b && a-x < b)
assertNotEquals a != b
assertSame a === b
assertNotSame a !== b
assertNull value === null
assertNotNull value !== null
assertUndefined value === undefined
assertNotUndefined value !== undefined
assertEmpty value == null (equals == undefined)
assertNotEmpty value != null (equals != undefined)
assertInfinity value === Infinity
assertNotInfinity value !== Infinity
assertThrows call(arguments) throws exception
assertNotThrows call(arguments) doesnt throw exception
assertTypeOf value typeof type
assertInstanceOf value instanceof type
You have also got the possibility to simple fail the Testcase by fail.

Field Index

DEFAULT_MAX_DIFF

Method Index

getResultFactory(), getTestRunner(), run(), setTestRunner(), setUp(), tearDown()

Inherited from BasicClass

toString()

Field Detail

DEFAULT_MAX_DIFF

static public DEFAULT_MAX_DIFF:Number

Method Detail

getResultFactory

public function getResultFactory(Void):TestResultFactory

Returns a factory to create a Result

Return

Factory for a result for this test.

Specified By

getResultFactory() in org.as2lib.test.unit.Test

setUp

public function setUp(Void):Void

Template method to set up the testcase before running a method. This method will get called before executing each method in a clean, new instance.

tearDown

public function tearDown(Void):Void

Template method to tear down the testcase after running a method. This method will get called after the execution of each method of this testcase.

run

public function run():TestRunner

Runs this testcase. Implementation of @see Test. Runs all methods of this testcase in an new container.

Return

Runner of the Testcases (containing all informations about the run)

Specified By

run() in org.as2lib.test.unit.Test

setTestRunner

public function setTestRunner(testRunner:TestRunner):Void

Setter for the testrunner. The testrunner represents the context of the actual method. getMethodInformation is a referred to the informations that represent this methods information. It will be automatically set by the testrunner, because only it know who runs this test)

Parameters

testRunnerUsed testrunner for this testcase.

getTestRunner

public function getTestRunner(Void):TestRunner

Getter for the testrunner. The testrunner represents the context of the actual method. The testrunner is usually only available within a testunit run.

Return

Current testrunner.