I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of FlexUnit but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Eclipse). Does one exist?

Also, are there any other resources on how to do Flex development "the right way" besides the Cairngorm microarchitecture example?

Edit: Thanks for the great replies. Unfortunately SO will only let me accept one answer, so due to reasons of not having tried either approach yet, I decided to accept the one that came first. Upmods for both, though. :)


There is a great article about this on Adobe:

They call it FlexUnit, seems to have most of what you are looking for.

Nick Berardi

Thanks for your answer, but...

As far as I can tell, FlexUnit compiles into a swf file that runs my tests. While that's somewhat better than nothing, I don't see an obvious way to do IDE or build script integration with it. Also, if you take a close look, I mentioned FlexUnit in my question. :)

+2  A: 

The dpUint testing framework has a test runner built with AIR which can be integrated with a build script.

There is also my FlexUnit automation kit which does more or less the same for FlexUnit. It has an Ant macro that makes it possible to run the tests as a part of an Ant script, for example:

<target name="run-tests" depends="compile-tests">
  <flexunit swf="${build.home}/tests.swf" failonerror="true"/>
+2  A: 

About how to develop Flex applications the right way, I wouldn't look too much at the Cairngorm framework. It does claim to show "best practice" and so on, but I would say that the opposite is true. It's based around the use of global variables, and other things you should try to avoid. I've outlined some of the problems on my blog.

I would suggest that you look at the Mate framework instead, which has good documentation and good examples to get you going. It uses Flex to its full potential, doesn't rely on global variables as Cairngorm and PureMVC, and it makes it possible to write much more decoupled code.

+3  A: 

On my project we're using Maven to build both our Flex RIA and the Java-based back end. In order to build and test the Flex app we use the flex-mojos maven plugins. They do a great job for us and I would highly recommend using Maven over Ant.

That being said, if you're already using Ant it can be a little tricky to transition over to Maven. So if you're in that position I would recommend using the flexunit tasks available here:

Both of these libraries do basically the same thing, they launch a generated flexunit test runner mxml application in a window and open a socket connection back to the build process using a JUnit test runner. Amazingly enough it works pretty well. The only problem is that you can't run it headless so if you want to run the build from a CI server you have to make sure that process has the ability to launch new windows otherwise it won't work.

Mike Deck

An alternative to FlexUnit is the AsUnit testing tools. There are versions for actionscript 2 and 3. It also has good integration with Project Sprouts, which is a build tool for Flex and Flash similar to ant, however it uses ruby rake tasks and includes excellent dependency management along the lines of maven.

No IDE integration that I know of however.


Can you describe what sort of IDE integration you want?


Here's a blog entry about FlexUnit and Ant: