|
From: Luke B. <lb...@gm...> - 2005-06-07 05:55:58
|
Great Question -
Yes.
The easiest way is to use com.asunit.util.TextFile. You can check that
class for required params and whatnot. The important thing is that
when the file is loaded, it will trigger an "onTextFileLoaded" on the
object that is set as it's callback. This should be your concrete
TestCase.
Your Test case will need some methods like the following:
private var mockData:TextFile;
private var instance:YourClass;
// Override the run function and request the XML
private function run():Void {
// I usually put my Mock data into the same package as my
Class Under Test (CUT)
mockData =3D new
TextFile("com/yourdomain/yourproject/YourClassMock.xml", this);
}
// Once the XML is loaded, call super.run()
// It's that simple...
public function onTextFileLoaded(txtFile:TextFile):Void {
super.run();
}
public function setUp():Void {
// Make a deep clone of your data in case any of your tests
make changes to it.
var safeDataInstance:XML =3D mockData.cloneNode(true);
instance =3D new YourClass();
}
I hope that helps!
Luke Bayes
www.asunit.com
|