FlexUnit 4 und TeamCity


In an earlier blog article we described how we integrated FlexUnit testing into our continuous integration process.

In the meanwhile a lot changed. First we switched from FlexUnit to funit which seemed much more lightweight and came with out-of-the-box TeamCity support. Then FlexUnit 4 came up and IntelliJ IDEA 9 was released including a built-in FlexUnit runner. That alone would have been reason enough to switch over again, but additionally FlexUnit 4 seems to be a huge improvement over the 0.9 predecessor.

Since FlexUnit 4 is now based on JUnit 4.5 it was a snap to port the TeamCityListener from funit over to FlexUnit, and since Hamlet complained last time on how we share code I this time did a fork of FlexUnit on github and applied my patch there.

Everything works great now!

Previous Post
Structure101g AS Screencast
Next Post
24. Wispri: Hindernisse auf dem Weg zum Ziel beseitigen

Related Posts

AsFlavor: Structure101g for Flex and Actionscript

Together with “The Structure Guys” from Headway Software we developed an Actionscript “flavor” for their latest Structure101 product family member Structure101g(eneric). AsFlavor makes the same esteemed structural and architectural analysis functionality available to the Flex and Actionscript community, that is well known to Java and C++ developers since years.

Read More

8 Comments. Leave new

Hi Harald, I’m just taking a look into this now and was wondering if you could explain how you are running your tests under TeamCity?

We’re using ant with the flexunit ant task here and the tracing to std out by the TeamCityListener is not getting picked up. How do you get this trace into the TeamCity logs using ant?



@ Mike

You have to add the listener to your test runner manually:

private function run():void {
    var core:FlexUnitCore = new FlexUnitCore();
    core.addListener(new TeamCityListener());

other than that, we don’t do anything special, we just run the swf within the flashplayer within ant with:

<exec executable="${player.home}/flashplayer">
    <arg line="${bin.dir}/TeamCityTestRunner.swf"/>



@ Harald Radi

Thanks Harald, I had part one in place but was using flex ant task to build.

Switching over to use exec I’m noticing that the flash player will not obviously close once tests are complete.

Our build process compiles a number of test swfs so this means the build will freeze up unless we spawn a new player instance for each test. We then need to kill these at the end of the build. This raises an issue if the tests aren’t complete when we do the final kill.

How do you get around closing the player once tests are complete?


Just looking over your source I see you call fscommand(“quit”); once the tests are complete. Not sure why this isn’t closing the standalone player for me. I’ll recompile and do some digging.


@ Mike

The player should actually close itself properly, the only hint i could give is not to use other listeners together with the TeamCityListener as they could prevent the player from closing properly.


OK so I’ve got everything in place like you said but still no trace output from the flash player to the teamcity logs. If I run the ant script locally I don’t see any trace output either, just:

Buildfile: C:\build.xml
[mxmlc] Loading configuration file C:Program Files (x86)AdobeAdobe Flash Builder 4sdks4.1.0frameworksflex-config.xml
[mxmlc] C:\testflexUnit-runnerShellUnitTestRunner.swf (737742 bytes)
Total time: 5 seconds

The runner task is exactly like you specified above and opens, runs and closes the test swf.

If I run the tests under FlashBuilder I see the teamcity traces as expected. Also worth saying that if I add the XMLListener I can confirm the tests do run when compiling through Ant.

Sorry for the repeat updates. Any pointers appreciated on how to get trace out through Ant.


Just to close this off, I’ve update your TeamCityListener to broadcast results over a socket and updated FlexUnitTask with an option to prints what it receives to std out. This is all working great now. If I get a sec this weekend I’ll do a fork with these updates on githhub.



Hey Mike,

Did you ever fork and make these changes to the TeamCityListener?



Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed