FlexUnit Visual Listener

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.

So, in place of trace, I present: Green Dots (a.k.a. FlexUnit Visual Listener):

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!).

Bonus! It’s simple to use too. Here’s an example:

(example_flexunitvisuallistener.as) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package
{
    import noiseandheat.flexunit.visuallistener.VisualListener;

    import org.flexunit.internals.TraceListener;
    import org.flexunit.runner.FlexUnitCore;
    import org.fluint.uiImpersonation.VisualTestEnvironmentBuilder;

    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;

    [SWF(backgroundColor="#000000", frameRate="120", width="800", height="600")]
    public class TestRunner extends Sprite
    {
        private var core:FlexUnitCore;
        private var listener:VisualListener;

        public function TestRunner()
        {
            core = new FlexUnitCore();
            VisualTestEnvironmentBuilder.getInstance(this);

            listener = new VisualListener();
            addChild(listener);
            core.addListener(listener);

            // Add a trace listener too if you want some trace output core.addListener(new
            TraceListener(800, 600));

            core.run(NoiseAndHeatSuite);

            addEventListener(Event.ADDED_TO_STAGE, addedToStage);
        }

        protected function addedToStage(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.

Grab it while it’s hot from: https://github.com/mnem/flexunit_visual_listener.