org.as2lib.core.BasicClass +--org.as2lib.test.unit.TestCase
Test
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 |
public function getResultFactory(Void):TestResultFactory
Returns a factory to create a Result
Factory for a result for this test.
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.
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.
public function run():TestRunner
Runs this testcase. Implementation of @see Test. Runs all methods of this testcase in an new container.
Runner of the Testcases (containing all informations about the run)
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)
testRunner | Used testrunner for this testcase. |
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.
Current testrunner.