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,
Labriola

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Conrad Winchester's Gravatar Thanks, that's really impressive.

I look forward to your CI solution :-)
# Posted By Conrad Winchester | 6/6/09 4:49 AM
Nicholas Hillier's Gravatar 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?

Thanks
# Posted By Nicholas Hillier | 6/9/09 3:09 PM
Michael Labriola's Gravatar 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,
Mike
# Posted By Michael Labriola | 6/9/09 3:15 PM
wvet's Gravatar 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
# Posted By wvet | 6/17/09 11:14 AM
Michael Labriola's Gravatar 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.
# Posted By Michael Labriola | 6/17/09 11:20 AM
craig's Gravatar +1 for Hudson (or other CI) support
# Posted By craig | 7/10/09 11:06 AM
Elisabeth Boonin's Gravatar What's the latest on ANT tasks for FlexUnit 4? Any ETA?
# Posted By Elisabeth Boonin | 7/16/09 3:45 PM
Michael Labriola's Gravatar Very basic ANT tasks and CI integration will be released today
# Posted By Michael Labriola | 8/3/09 9:47 AM
moose's Gravatar Where do I find these basic ANT tasks?
# Posted By moose | 8/5/09 5:43 AM
Conrad Winchester's Gravatar Hi Mike,

any idea when that release will happen?
# Posted By Conrad Winchester | 8/6/09 1:27 AM
Micah Douglas's Gravatar +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.
# Posted By Micah Douglas | 8/6/09 10:21 AM
Michael Labriola's Gravatar All:

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.
# Posted By Michael Labriola | 8/6/09 11:29 AM
Conrad Winchester's Gravatar 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

Conrad
# Posted By Conrad Winchester | 8/14/09 2:18 AM
JD Conley's Gravatar I'm also very interested in the Ant packages for FlexUnit 4. I don't see them yet on the Adobe site... :)
# Posted By JD Conley | 8/14/09 12:47 PM
Giles Roadnight's Gravatar 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.
# Posted By Giles Roadnight | 8/20/09 3:45 AM
JD Conley's Gravatar 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/b.... The Ant script is in /trunk/build ("test" target) and the AIR code for the runner is at /trunk/test/src/.
# Posted By JD Conley | 8/24/09 5:24 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001.