|
From: Luke B. <lb...@gm...> - 2005-01-11 19:13:03
|
Bert,
There should be an implementation of the TestSetup class shipped with
the latest version of AsUnit. (2.5+)
The purpose of this class, as I understand it, is to only execute
setUp and tearDown one time for the test case.
The question (as I understand it) was more related to asynchronous
execution of the entire TestCase. So there might still be a desire to
run setUp and tearDown around each "test" method, but there is a need
to pause execution of the entire test Case until some other task has
completed..
This can be done by overriding the "run" method in your concrete
TestCase class, and then providing a callback function that calls
"super.run();" which will begin execution after whatever requisite
event has occurred.
Here is an example from within a concrete TestCase
// declare the member variable
// ModuleData extends XML and calls ctrl.onXmlLoaded
// inside the xml onLoad handler.
private var mockData:ModuleData;
// String target to the XML dock (We usually put them next to the
// class under test directly in the packages...)
private var mockDataSrc:String = "com/fastcountry/controls/SomeControlMock.xml";
// Over-ride the built-in run method and instantiate
// a custom XML Object (one time for entire test case)
// This custom XML Object will load the document at
// mockDataSrc...
private function run():Void {
mockData = new ModuleData(mockDataSrc, this);
}
// This is called from the ModuleData class after
// the requested XML is loaded.
public function onXmlLoaded():Void {
super.run();
}
// It's important to use the .clone method of the XMLNode
// so that you get clean, unmanipulated data for each
// test method.
public function setUp():Void {
var initObj:Object = new Object();
initObj.node = mockData.firstChild.cloneNode(true);
instance = TabPanel(LayoutElementFactory.getInstance(_root,
TabPanel.linkageId, initObj));
}
I hope that helps!
Thanks,
Luke Bayes
www.asunit.com
|