Let’s face it, we all use Flash and AS3 because we like pretty eye candy.
Otherwise we’d just use a real language.
In light of that, I’ve never been particularly happy with the standard
AS3 FlexUnit listener you get when you aren’t running inside FlashBuilder. Trace
statements are so last century. Also, they give me flashbacks to embedded C
programming, and I have to go and brick a firmware. I’m running out of phones.
They’re totally contemporary, work with any dress and are a stylish addition
to every modern CI system. They even give you some useful error information
when you roll the mouse over the test result dot (which you can copy to the
clipboard by clicking. Awesome!).
package{importnoiseandheat.flexunit.visuallistener.VisualListener;importorg.flexunit.internals.TraceListener;importorg.flexunit.runner.FlexUnitCore;importorg.fluint.uiImpersonation.VisualTestEnvironmentBuilder;importflash.display.Sprite;importflash.display.StageAlign;importflash.display.StageScaleMode;importflash.events.Event;[SWF(backgroundColor="#000000",frameRate="120",width="800",height="600")]publicclassTestRunnerextendsSprite{privatevarcore:FlexUnitCore;privatevarlistener:VisualListener;publicfunctionTestRunner(){core=newFlexUnitCore();VisualTestEnvironmentBuilder.getInstance(this);listener=newVisualListener();addChild(listener);core.addListener(listener);// Add a trace listener too if you want some trace output core.addListener(newTraceListener(800,600));core.run(NoiseAndHeatSuite);addEventListener(Event.ADDED_TO_STAGE,addedToStage);}protectedfunctionaddedToStage(event:Event):void{removeEventListener(Event.ADDED_TO_STAGE,addedToStage);stage.align=StageAlign.TOP_LEFT;stage.scaleMode=StageScaleMode.NO_SCALE;}}}
It’s similar to the normal FlexUnit runner example, but with the addition of
the VisualListener and stage tweaks.