actionscript-3unit-testingeventsflexunit

Setting Event.target for using events in unit testing


I want to override flash.display.Loader and to dispatch my own Event with a my own target.content

How can i override Event.target? "Property is read only"

Or use some other way to unit test the loading sequence

tnx Hed


Solution

  • The target is always set to the object that dispatches the event. The proper way to unit test loading sequence is to mock the loaders - this unit test should test the logic used for loading sequentially, not the file system or network connection.

    Wrap your loader into a custom class implementing a custom loader interface that extends IEventDispatcher. Use that interface to create a mock loader, and dispatch the event from the mock object.