Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ant xml example for FLEX/AS3 code unit test.
<!--
This is intended to be a simple build file, created a suggestion for the necessary steps need to utilize the FlexUnit4 Ant task.
For the most detail when running this build, call "ant -v clean package". The build uses a simple lifecycle of:
clean->init->compile->test->package
The end goal is to produce a zip of a website you could deploy for your application. This build is not intended to be an example
for how to use Ant or the Flex SDK Ant tasks. This is just one possible way to utilize the FlexUnit4 Ant tasks.
-->
<project name="XXX_Flex_UnitTest" basedir="." default="test">
<!-- setup a prefix for all environment variables -->
<property environment="env" />
<!-- Setup paths for build -->
<property name="main.src.loc" location="${basedir}/src/" />
<property name="test.src.loc" location="${basedir}/src/" />
<property name="lib.loc" location="${basedir}/libs" />
<property name="output.loc" location="${basedir}/target" />
<property name="bin.loc" location="${output.loc}/unittest/bin" />
<property name="report.loc" location="${output.loc}/unittest/report" />
<property name="dist.loc" location="${output.loc}/unittest/dist" />
<!-- Setup Flex and FlexUnit ant tasks -->
<!-- You can set this directly so mxmlc will work correctly, or set FLEX_HOME as an environment variable and use as below -->
<property name="FLEX_HOME" location="C:\Flex\sdks\flex_sdk_3.5.0_code_coverage" />
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<taskdef resource="flexUnitTasks.tasks">
<classpath>
<fileset dir="${lib.loc}">
<include name="unittest/flexUnitTasks*.jar" />
</fileset>
</classpath>
</taskdef>
<target name="clean">
<!-- Remove all directories created during the build process -->
<delete dir="${output.loc}" />
</target>
<target name="init">
<!-- Create directories needed for the build process -->
<mkdir dir="${output.loc}" />
<mkdir dir="${bin.loc}" />
<mkdir dir="${report.loc}" />
<mkdir dir="${dist.loc}" />
</target>
<!-- Compile Main.mxml as a SWF -->
<!-- <target name="compile" depends="init">-->
<!-- <mxmlc file="${main.src.loc}/Main.mxml" output="${bin.loc}/Main.swf">-->
<!-- <library-path dir="${lib.loc}" append="true">-->
<!-- <include name="*.swc" />-->
<!-- </library-path>-->
<!-- <compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>-->
<!-- <compiler.headless-server>true</compiler.headless-server>-->
<!-- </mxmlc>-->
<!-- </target>-->
<target name="test" depends="init">
<!-- Compile TestRunner.mxml as a SWF -->
<mxmlc file="${test.src.loc}/FlexUnitApplication.mxml" output="${bin.loc}/FlexUnitApplication.swf">
<source-path path-element="${main.src.loc}" />
<library-path dir="${lib.loc}" append="true">
<include name="*.swc" />
<include name="unittest/*.swc" />
<include name="qtp/*.swc" />
</library-path>
<compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
<compiler.headless-server>true</compiler.headless-server>
</mxmlc>
<!--Wait Java file IO time-->
<echo>Sleep 10 seconds for file IO</echo>
<sleep seconds="10"/>
<!-- Execute CodeCoverView with arguments through VNC server-->
<echo>Open /usr/bin/CoverageViewer</echo>
<exec executable="/bin/bash">
<arg value="/opt/APB_SAAS_II_WAR/coverage_startup.sh" />
</exec>
<echo>Sleep 10 seconds for CoverageViewer get ready</echo>
<sleep seconds="10"/>
<!-- Execute TestRunner.swf as FlexUnit tests and publish reports -->
<flexunit
player="flash"
swf="${output.loc}/unittest/bin/FlexUnitApplication.swf"
toDir="${report.loc}"
haltonfailure="false"
verbose="true"
localTrusted="true"
headless="${HEADLESS}"
/>
<!-- Headless mode can only be used on Linux with vncserver installed.-->
<!-- headless="true" -->
<!-- <flexunit player="air" -->
<!-- workingDir="${bin.loc}"-->
<!-- toDir="${report.loc}" -->
<!-- haltonfailure="false" -->
<!-- verbose="true">-->
<!-- <source dir="${main.src.loc}" />-->
<!-- <testSource dir="${test.src.loc}">-->
<!-- <include name="**/*Test.as" />-->
<!-- </testSource>-->
<!-- <library dir="${lib.loc}" />-->
<!-- </flexunit> -->
<!-- Close CodeCoverView with default save Emma report xml file-->
<sleep seconds="100"/><!--This timer for delay-based playing unittest swf time-->
<!-- Execute CodeCoverView with arguments through VNC server-->
<echo>Close /usr/bin/CoverageViewer</echo>
<exec executable="/bin/bash">
<arg value="/opt/APB_SAAS_II_WAR/coverage_quit.sh" />
</exec>
<!--When killing a process or series of processes, it is common sense to start trying with the least dangerous signal, SIGTERM.-->
<!--That way, programs that care about an orderly shutdown get the chance to follow the procedures -->
<!--that they have been designed to execute when getting the SIGTERM signal,such as cleaning up and closing open files. -->
<!--If you send a SIGKILL to a process, you remove any chance for the process to do a tidy cleanup and shutdown, which might have unfortunate consequences.-->
<!-- <exec executable="kill">-->
<!-- <arg value="-15"/>-->
<!-- <arg value="CoverageViewer"/>-->
<!-- </exec>-->
<!-- Generate readable JUnit-style reports -->
<junitreport todir="${report.loc}">
<fileset dir="${report.loc}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.loc}/html" />
</junitreport>
</target>
<!-- <target name="package" depends="test">-->
<!-- Assemble final website -->
<!-- <copy file="${bin.loc}/Main.swf" todir="${dist.loc}" />-->
<!-- <html-wrapper swf="Main" output="${dist.loc}" height="100%" width="100%" />-->
<!-- Zip up final website -->
<!-- <zip destfile="${output.loc}/${ant.project.name}.zip">-->
<!-- <fileset dir="${dist.loc}" />-->
<!-- </zip>-->
<!-- </target>-->
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.