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
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
Hi Mike, thanks a lot for your answer. I was looking at the CI examples but I think I still don't understand how to get it to work with the AirCIListener. My main looks like this:
function init():void
{
var core : FlexUnitCore = new FlexUnitCore();
core.addListener(new AirCIListener());
core.run( SampleTest);
}
Its just like in the examples, but flexunit still won't close and still won't write anything to disk. From your answer, if I understand correctly for the tests to run and have output written to disk I would have to have 2 executables running at the same time, one of them being my tests with flexunit and the other one being an executable that I must write myself in my language of choice which will listen on a specific port for the results which will be sent from the flexunit. My second executable will then get those results and write them down?
Franco
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
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:
and
Mike
North America
Europe, Middle East and Africa
Asia Pacific