Skip to main content
Participant
August 30, 2008
Question

addAsync in setUp()

  • August 30, 2008
  • 2 replies
  • 812 views
I would like to add an async function inside the setUp() of a test, but FlexUnit generates an error to the effect that the function argument is not a function. Is running async function in a setUp() supported? I would appreciate any advice on this.

Basically, what I'm trying to do is to perform some end-to-end testing of business methods inside FlexUnit, and those methods need to call methods on the server. Because the methods alter state on the server, I want to be able to clear up any changes to server-side state performed during the tests. Thus, I need to invoke remote methods inside the setUp() methods of a test suite; and I need to ensure that each test case executes only after the setUp() method receives events from the remote method indicating successful return.

Again, I'd very much appreciate any suggestions as to how this may be achieved.

Thanks,

-- Frank
This topic has been closed for replies.

2 replies

Participant
October 7, 2008
I've logged a feature request for this:
https://bugs.adobe.com/jira/browse/FXU-20
Participant
September 5, 2008
You can use the following:

package tests {
import flash.net.URLLoader;
import flash.net.URLRequest;

import flexunit.framework.TestResult;
import flexunit.framework.TestSuite;

public class ViewTests extends TestSuite {
private var _result:TestResult;

override public function runWithResult(result:TestResult):void {
_result = result;

// Do any upfront stuff here.
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest("config.xml"));
}

private function completeHandler(event:Event):void {
super.runWithResult(_result);
}
}
}