*New* FlexAntTask – fails build if test suite doesn’t execute

The FlexAntTask will now fail the build if there is an error executing the test suite e.g. a socket timeout. In the past the error was swallowed as the server socket runs in a separate thread – any errors are now passed back to the task and re-thrown.

Binary distribution


Source Distribution


Example Project


Ant Task Parameters

swf The name of SWF containing the tests to execute. Yes
port The port to receive the test results on from FlexUnit. The default port is 1024. No
timeout The time in milliseconds to wait for results from FlexUnit before stopping the building process. The default is 60 seconds. You need to allow enought time for your tests to run as the socket is opended prior to the test execution. No
toDir The output directory for the test resutlts. The default is the working directory. No
haltonfailure Stop the build process if a test fails. The default is true. No
failureproperty The name of the property to set in the event of a failure. The default is ‘flexunit.failed”. No
verbose Causes the flexunit tasks to print status messages. The default is false. No

14 Responses to *New* FlexAntTask – fails build if test suite doesn’t execute

  1. Mark says:

    HI Peter,This might seem like a stupid question… So please bear with me…I have been trying to get FlexUnit and Flex working with Ant. I noticed your great posts about FlexUnit Ant Tasks…My question is.. Does the binary FlexAntTasks you have linked include the FlexAntTasks required to build flex applications as well? I.e. would I use these as a replaced to the ones supplied in the Flex 3 SDK?Thanks for your help in advancePlease keep the great Flex Unit Ant posts coming.RegardsMark

  2. Peter Martin says:

    Thanks for the comment Mark.We seem to having a naming clash here. They are two different things. You will need both. I will look to rename mine or ideally see if I can my FlexUnitTask pushed in to the other FlexAntTasks.

  3. Tim Robles says:

    Peter-Thanks for this. I hope it gets integrated into the flexunit project soon (which I also would love to contribute to!). Anyways, I think another caveat that isn’t mentioned is that you do in fact need to specify the port # within your test runner mxml to match whatever you specify with the flexunit task. Is there a more elegant way to inject the port # to the swf w/o jumping through hoops in terms of passing some parameters to the swf through the command line?-Tim

  4. Kieran says:

    Hi Peter,Thanks very much for your FlexUnit Ant task, it’s a massive help for a lot of us Flex developers.One thing that I wanted to do was make it a bit easier to make it run headless. I’ve made the changes so that when running on Linux/Unix, you can pass in an extra parameter to the flexunit task that tells it what display to spawn the flashplayer on.Hopefully you’ll get your task added to the main Adobe flex ant tasks, but in the mean time, would you open source it and put it up on Google Code or somewhere for us to contribute?Thanks a lot,Kieran

  5. Peter Martin says:

    Hi Tim,It will get moved over to the FlexUnit project, I have an action to do something about it :)I didn’t think of setting the port# on the URL, good idea, I will take a look.CheersPeter.

  6. Peter Martin says:

    Hi Kieran,I am interested to see what you have done around headless to make it easier.The plan is to move this code on to opensource.adobe.com under the FlexUnit project. I just need to make some time :)ThanksPeter.

  7. Kieran says:

    Hi Peter,It’s be great to see it integrated into the main Adobe code. I think a lot of people are using your stuff but I’m sure people better than I could make it even better.Basically all that I did was change the UnixSWFLauncher slightly so that it can take environment variables, or more specifically, you can put a “display” attribute on the flexunit task and it’ll add the “DISPLAY=:5” or something like that to the exec that launches the flash player. My ant script then starts and stops a VNC server on the right display before/after the tests.This could be done by setting the DISPLAY in a script before you even run the ant build, but I prefer a pure ant solution. Although I must admit I’m having trouble with my continuous build in Hudson at the moment as it seems to be spawning the ant task is some strange way that it isn’t picking up my FlashPlayerTrust directory settings :(Kieran

  8. Marcus Stade says:

    How do you use this when there are spaces in a path? It seems as though spaces aren’t escaped correctly and so if you have spaces in the file path (such as /User/marcus/Documents/Flex Builder 3/) the launch will fail. Is there any way around this short of modifying the source code to the launcher?

  9. peter royal says:

    another +1 on getting this into the main flexunit svn.once enhancement i’d like to add is to have it send the stack trace to the clients, and it would be preferable to send a patch to an existing repo rather than forking the project.

  10. Peter Martin says:

    Hi Marcus,I haven’t seen this issue before so I don’t know any immediate workarounds. I will take a look.ThanksPeter.

  11. Dozz says:

    Hello Peter,I got this error when running flex unit from ant script. Do you know what happened here?## An unexpected error has been detected by HotSpot Virtual Machine:## EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d80f849, pid=980, tid=5532## Java VM: Java HotSpot(TM) Client VM (1.5.0_15-b04 mixed mode, sharing)# Problematic frame:# V [jvm.dll+0xcf849]## An error report file with more information is saved as hs_err_pid980.log## If you would like to submit a bug report, please visit:# http://java.sun.com/webapps/bugreport/crash.jsp#

  12. Peter Martin says:

    Hi Peter,After MAX I promise to get the FlexUnit Ant task in to SVN, it is on my list of things to do.CheersPeter.

  13. Peter Martin says:

    Hi Dozz,Ouch, not seen that one before.I found a couple of similar things on the Sun forums, but nothing too helpful:http://forums.sun.com/thread.jspa?threadID=5313996http://forums.sun.com/thread.jspa?threadID=5278505&tstart=270Can you try with a different JVM?CheersPeter.

  14. Harald Radi says:

    I patched you ant task to output log messages in a TeamCity understandable format. That way TeamCity can show the testresults and will also maintain statistics. If you are interested in that patch drop me a note on how to get in contact with you.