Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ant xml example(flexunit-with-code-coverage) for FLEX/AS3 code unit test with code coverage reporting.
<?xml version="1.0" encoding="UTF-8"?>
<project name="flexunit-with-code-coverage" default="test" basedir=".">
<!-- =========================================================================================================================================
============================================================= PROPERTY DEFINITIONS =============================================================
========================================================================================================================================== -->
<property environment="env" />
<property name="FLEX_HOME" value="C:\Software\FLEX\sdks\4.6.0" />
<property name="output.loc" value="${basedir}/target" />
<property name="src.dir" value="${basedir}/src" />
<property name="lib.dir" value="${basedir}/libs" />
<property name="build.dir" value="${lib.dir}/build" />
<property name="report.dir" value="${output.loc}/codecoverage" />
<path id="buildtools.classpath">
<fileset dir="${build.dir}" includes="*.jar" />
</path>
<!-- =========================================================================================================================================
=============================================================== TASK DEFINITIONS ===============================================================
========================================================================================================================================== -->
<taskdef name="mxmlc" classname="flex.ant.MxmlcTask" classpathref="buildtools.classpath" />
<taskdef name="compc"
classname="flex.ant.CompcTask"
classpathref="buildtools.classpath"/>
<taskdef resource="flexUnitTasks.tasks">
<classpath>
<fileset dir="${lib.dir}/test">
<include name="flexUnitTasks*.jar" />
</fileset>
</classpath>
</taskdef>
<!-- =========================================================================================================================================
========================================================== INITIALIZATION TARGETS ==========================================================
========================================================================================================================================== -->
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="init" >
<mkdir dir="${build.dir}" />
</target>
<!-- =========================================================================================================================================
=========================================================== SWC TARGETS ==========================================================
========================================================================================================================================== -->
<target name="build-swf" depends="init">
<mxmlc file="${src.dir}/swf/org/included/ExampleApp.mxml" output="${build.dir}/ExampleApp.swf"
strict="true" debug="true" compiler.debug="true" incremental="false"
maxmemory="1024m" optimize="true" fork="true" static-link-runtime-shared-libraries="true">
<default-frame-rate>24</default-frame-rate>
<source-path path-element="src/swf" />
<show-unused-type-selector-warnings>false</show-unused-type-selector-warnings>
</mxmlc>
</target>
<target name="build-test-swf" depends="build-swf">
<mxmlc file="src/test_swf/TestRunner.mxml" output="${build.dir}/TestRunner.swf" strict="true" debug="true" incremental="true"
maxmemory="1024m" optimize="true" fork="true" static-link-runtime-shared-libraries="true">
<default-frame-rate>24</default-frame-rate>
<source-path path-element="src/swf" />
<source-path path-element="src/test_swf" />
<show-unused-type-selector-warnings>false</show-unused-type-selector-warnings>
<include-libraries dir="${lib.dir}/test">
<include name="flexunit-uilistener-4.1.0-3JG-4.6.0.23201.swc" />
<include name="flexunit-4.1.0-3JG-flex_4.6.0.23201.swc" />
<include name="flexunit-cilistener-4.1.0-3JG-4.6.0.23201.swc" />
</include-libraries>
</mxmlc>
</target>
<target name="test" depends="build-test-swf">
<mkdir dir="${report.dir}" />
<flexunit
workingDir="${build.dir}"
toDir="${report.dir}"
swf="${build.dir}/TestRunner.swf"
haltonfailure="false"
verbose="true"
localTrusted="true"
timeout="400000"
headless="false"
debug="true"
port="1024">
<coverageSource>${src.dir}/swf/</coverageSource>
<coverageExclude>org.excluded</coverageExclude>
</flexunit>
<!-- Generate readable JUnit-style reports -->
<junitreport todir="${report.dir}">
<fileset dir="${report.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.dir}/html" />
</junitreport>
</target>
</project>
@yangboz

This comment has been minimized.

Copy link
Owner Author

commented Feb 20, 2014

Reference: http://www.copperykeenclaws.com/how-to-set-up-a-flex-unit-test-with-ant-and-hudson/
Notice:
1025 port has taken by the "wininit.exe" at Windows7 platform;
Download the "Projector" version of flash player , it needs to be associated with the running of swf files.

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.