Skip navigation
Franco Salas bitheads
Currently Being Moderated

Help using FlexUnit with Nant

Jan 13, 2012 1:53 PM

Hi,

 

I created some tests which run perfectly if I use my IDE (FlashDevelop) to run them. I've been trying to create a Nant script to automate my tests and have the results written into an xml file. The entire build system where I work uses Nant instead of Ant, so I can't really follow the Ant examples.

 

I am able to compile my main and my test classes into a swf like this:

 

    <target name="compile" depends="cleanup">

        <!-- mkdir dir="${executable.dir}" / -->

        <exec program="mxmlc.exe" workingdir="." verbose="true">

            <arg value="-compiler.strict" />

            <arg value="-compiler.source-path" />

            <arg value="..\engineunittests\src" />

            <arg value="-static-link-runtime-shared-libraries" />

            <arg value="-output" />

            <arg value="${executable.dir}\EngineUnitTests.swf" />

            <arg value="-compiler.include-libraries" />

            <arg value="${flexunit.dir}\flexunit-4.1.0-8-as3_4.1.0.16076.swc" />

            <arg value="${flexunit.dir}\flexunit-uilistener-4.1.0-8-4.1.0.16076.swc" />

            <arg value="--" />

            <arg value="${source.dir}\com\playbrains\metagame\test\Main.as" />

        </exec>

    </target>

 

That works fine, then I try to run it like this:

 

    <target name="runtest" depends="setup">

        <mkdir dir="${output.dir}" />

        <exec program="adl.exe" workingdir="${executable.dir}" verbose="true">

            <arg value="application.xml" />

            <arg value="--" />

            <arg value="${output.dir}" />

        </exec>

    </target>

 

This runs the swf and the tests but the problem is that it opens the air debug window and it never closes, and the results are never written on any xml file.

 

How can I configure my swf so that it stops the adl window when it is done and also write down the results on an xml file?

 

Thanks,

 

Franco

 
Replies
  • Currently Being Moderated
    Jan 13, 2012 1:56 PM   in reply to Franco Salas bitheads

    Franco,

     

    You are going to need to look at some of the CI ant examples. First, you need to be using the AIRCIListener, which both knows how to send results back to be written and second how to close the application when it was done.

     

    However, this code by itself can not write the results. Our ant tasks also launch a small piece of Java code which listens for those results and writes them to the file system. You will need to make that work as well.

     

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 8:46 AM   in reply to Franco Salas bitheads

    Your init looks fine and is correct.

     

    However, yes, it requires another executable. The AIRCIListener sends information over a socket to a waiting executable that receives and writes those results to the disk. We have one written for you in Java already, should you want to use it. If you would like to take a look, here is the code:

     

    Although it is part of out 'ant' package of tools, it is just Java code:

     

    https://github.com/flexunit/flexunit/tree/master/FlexUnit4AntTasks/src /org/flexunit/ant

     

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 9:56 AM   in reply to Franco Salas bitheads

    Since you are using AIR. If you wanted to, the other thing you could do is copy the AIRCIListener, and instead of having it send over the file system, you could use the AIR File API to write it directly to disk.

     

    These tools were developed to work with Flash Player or AIR and Flash Player does not have that ability.

     

    Take a look at:

     

    https://github.com/flexunit/flexunit/blob/master/FlexUnit4AirCIListene r/src/org/flexunit/listeners/AirCIListener.as

     

    and

     

    https://github.com/flexunit/flexunit/blob/master/FlexUnit4CIListener/s rc/org/flexunit/listeners/CIListener.as

     

    Mike

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points