Skip to main content
Participant
October 9, 2010
Question

Test Script for Event driven function

  • October 9, 2010
  • 1 reply
  • 443 views

Hi,

i m new to this product. i have one doubt , is it possible to write test scripts for event driven functions ?

if possible, could you please share some samples.?

Thnk you.

Bala.

This topic has been closed for replies.

1 reply

Participating Frequently
October 9, 2010

Yes.

At the simplest, you could have a test like this:

[Test]

public function shouldThrowEvent():void {

  var eventCalled:Boolean = false;

  var someEventDispatcher:SomeEventDispatcher = new SomeEventDispatcher();

  someEventDispatcher.addEventListener( "someEvent",

          function ( event:Event ) {

               eventCalled = true;

          }

  assertTrue( eventCalled );

}

I would recommend looking at docs.flexunit.org for more information.

Mike