After the tests have completed successfully and the test runner has been removed from the stage so the project can run, resizing the flash player's window throws an exception:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at asunit.textui::TestRunner/resizeHandler()[as3\src\asunit\textui\TestRunner.as:84]
public function Main() {
var testing:Task = AllTests.RunShowAsync(this.stage);
testing.Await(function():void {
if (!testing.IsFaulted()) init();
});
}
package UnitTests {
import asunit.framework.TestResult;
import asunit.framework.TestSuite;
import asunit.textui.TestRunner;
import Async.Task;
import Async.TaskSource;
import Async.TaskUtil;
import flash.display.Stage;
import flash.errors.IllegalOperationError;
public class AllTests extends TestSuite {
private static var HACKY_LAST_INSTANCE:AllTests;
public function AllTests() {
super();
addTest(new TestAsync());
//... omitted ...
HACKY_LAST_INSTANCE = this;
}
public static function RunShowAsync(stage : Stage) :Task {
var r:TaskSource = new TaskSource();
var testRunner:TestRunner = new TestRunner();
stage.addChild(testRunner);
var testResult:TestResult = testRunner.start(AllTests, null, TestRunner.SHOW_TRACE);
var allTests:AllTests = HACKY_LAST_INSTANCE;
var queryResultLooper:Function = function():void {
if (!allTests.getIsComplete()) {
TaskUtil.Delay(100).Await(queryResultLooper);
return;
}
if (testResult.failureCount() > 0 || testResult.errorCount() > 0) {
r.SetFault(new IllegalOperationError("Test Failures"));
} else {
r.SetResult(null);
stage.removeChild(testRunner);
}
}
queryResultLooper();
return r;
}
}
}