Skip to main content
Participant
Oct 1, 2009 7:02 AM UTC
Question

testing events dispatch

newbie question.

The class I want to test dispatch events, how do I test for this the proper way? I only see tests about the result returns when calling a class ( whether the return is asynchrone or not, that's another topic I would say), but I think it's fair to also tests that events are properly fired isn't it? or am I going the wrong way?

Thanks,

Jean

This topic is closed to new replies. Start a new post to keep the conversation going.

1 reply

Participating Frequently
Oct 1, 2009 1:08 PM UTC

Jean,

If you just want to test that an event has been dispatched, you only need to use addEventListener.

[Test]

public function someTest():void {

  var someObj:SomeObjThatDispatchesEvents = new SomeObjThatDispatchesEvents();

   someObj.addEventListener( "someEvent", someFunc );

   someObj.causeEventToOccur();

}

private function someFunc( event:Event ):void {

//assert something based on the state of things

}

Translate