FlexUnit 4 and Flash Builder 4

So, suppose you are the kind of person who has downloaded the FlexUnit 4 turnkey beta from opensource.adobe.com. Suppose you are also the type of person who downloaded the new Flash Builder 4 beta from labs.adobe.com.
Well then perhaps you are thinking to yourself, “Self, I would really like to see the results from my FlexUnit 4 tests right inside of the FlexUnit Result view in Flash Builder. I wonder how I would do that.”

Well, I would personally suggest you add the following import to your FlexUnit4Turnkey.mxml file:

import org.flexunit.runner.notification.async.XMLListener;

And then add the following line before your call to the run method of the FlexUnit 4 core.

core.addListener( new XMLListener( "FlexUnit4Turnkey" ) );

Ideally, it will look something like this:

core = new FlexUnitCore();
core.addListener( new XMLListener( "FlexUnit4Turnkey" ) );
core.run( FlexUnit4Suite, HamcrestSuite, FlexUnitIn360 );

Where the string “FlexUnit4Turnkey” represents the name of the project where this MXML file resides. If you open the FlexUnit Results view in Flash Builder and execute this MXML file, you will see the results in Flash Builder.

Unfortunately, you need to be aware of some of limitations. First, Flash Builder doesn’t know how to generate these tests yet and will currently fail if you click any of the buttons such as Run All Completed Tests, Run All Failed Tests, etc. We can just give it back information about the success and failure, Flash Builder doesn’t yet know how to choose, run or specify FlexUnit 4 tests. Also, and perhaps more severely, Flash Builder considers any Ignored tests a pseudo-failure. Truthfully, it just doesn’t understand what we mean, so, in some cases, it looks like a failure, but in others it doesn’t.

Right now, FlexUnit 4 beta still also outputs to the console, which means Flash Builder will try to keep switching you over to the console view, but this will be a little cleaner in our (FlexUnit’s) next beta drop. In either case, it is perhaps a bit of a novelty for the moment, but it demonstrates the power of the listener model that FlexUnit 4 uses. Wait till you see the stuff coming for Continuous Integration :)

Cheers and have fun,



    Thanks, that’s really impressive.

    I look forward to your CI solution :-)

    • by Conrad Winchester
    • 4:06 am, June 6, 2009
    • Reply

    Hey guys

    Just wondering how far away we are from getting the FlexUnit4CIRunner going? I am looking for a good solution for integrating with Hudson, and right now the best documented solution is Peter Martin’s FlexAntTask.jar.

    However, unless I integrate his JUnitTestRunner with FlexUnit4, I’m pretty much stuck working with FlexUnit1. Is there a tutorial or more information out there regarding the use of the CI Runner in FlexUnit4?


    If you take a look in the SVN repository, there is some early work there. However, we just hit our first beta milestone. We will be ready with full CI work at release, but right now we are focusing on ensuring the framework itself is stable, (mostly) bug free and has the functionality we want.

    Will keep you posted as we go forward,

    Am I able to run an automate FU4 test suite in ant for a FB3 project? We have FU1 running now but would like to move to FU4. Is it backwardly compatible

    • by wvet
    • 11:06 am, June 17, 2009
    • Reply

    Tests are backwards comptible. The ant tasks are not as the executables are different.

    We haven’t published the new ones yet, so if you need this feature, you will need to wait.

    +1 for Hudson (or other CI) support

    What’s the latest on ANT tasks for FlexUnit 4? Any ETA?

    • by Elisabeth Boonin
    • 3:07 pm, July 16, 2009
    • Reply

    Very basic ANT tasks and CI integration will be released today

    Where do I find these basic ANT tasks?

    • by moose
    • 5:08 am, August 5, 2009
    • Reply

    Hi Mike,

    any idea when that release will happen?

    • by Conrad Winchester
    • 1:08 am, August 6, 2009
    • Reply

    +1 also for Hudson or CI and Ant Tasks for FU4.

    These projects build in 3.4 in flex builder 3 still right? We are working in both 3 and 4 to set up a transition plan for our Flex projects.


    Yes, the library is fully compatible with 3 and with 4.

    The ant tasks were delayed by a couple of days due to a bug in multiple suites but will be available tomorrow. Will post about them as soon as they are available.

    Hi Mike,

    any news on the CI side of FlexUnit 4? I am having a problem in that I can’t find the original FlexUnit ant tasks, all links to them are broken and I don’t have a copy.

    If you are finding it difficult to get the time together to work on the CI side of FU4 then I am willing to muck in nd write some code


    • by Conrad Winchester
    • 2:08 am, August 14, 2009
    • Reply

    I’m also very interested in the Ant packages for FlexUnit 4. I don’t see them yet on the Adobe site… :)

    Same here, we need to incorporate FlexUnit tests into our CI build and we’re holding off until we see what these tasks will do for us. On another project we had unit tests working in a CI build but it was a pain, I hope this way will be easier.

    I’m working on the PushButtonEngine game engine and we rolled our own using the code that’s in the FlexUnit repository… You can have a look at our test project and Ant scripts in our SVN: http://code.google.com/p/pushbuttonengine/source/browse/trunk. The Ant script is in /trunk/build ("test" target) and the AIR code for the runner is at /trunk/test/src/.

Leave a Reply