Skip to main content
Participant
October 1, 2009
Question

testing events dispatch

  • October 1, 2009
  • 1 reply
  • 739 views

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 has been closed for replies.

1 reply

Participating Frequently
October 1, 2009

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

}