Permalink
Browse files

Added Ant targets for running unit tests and continuous integrations:…

… "tests" and "ci".

Removed build-asunit.xml as its functionality has been merged into build.xml.
Added AllTestsCIRunner.
  • Loading branch information...
1 parent 26142f7 commit ce49004116812341c70f09a296a603bcff66c891 @robertpenner robertpenner committed Nov 14, 2010
@@ -1,7 +0,0 @@
-tests.output=${output.dir}/${ant.project.name}-tests.swf
-test.lib=${libs.dir}/asunit4-alpha.swc
-test.main=${tests.dir}/${package.dir}/AllTestsRunner.as
-
-flex.config=${FLEX_HOME}/frameworks/flex-config.xml
-flex.lib=${FLEX_HOME}/frameworks/libs
-flextask.jar=${FLEX_HOME}/ant/lib/flexTasks.jar
View
@@ -1,34 +0,0 @@
-<project name="as3-signals" basedir="." default="test">
-
- <!-- Set up a prefix for all environment variables. -->
- <property environment="env."/>
- <fail unless="env.FLEX_HOME" message="FLEX_HOME needs to be defined as an environment variable or in the Ant build." />
- <!-- Copy Flex SDK location from environment variable. This can be set manually instead. -->
- <property name="FLEX_HOME" value="${env.FLEX_HOME}" />
- <property file="build.properties"/>
- <property file="build-asunit.properties"/>
-
- <target name="test">
-
- <taskdef resource="flexTasks.tasks" classpath="${flextask.jar}" />
-
- <mxmlc file="${test.main}" output="${tests.output}"
- incremental="true" debug="false"
- static-link-runtime-shared-libraries="true">
- <source-path path-element="${src.dir}" />
- <source-path path-element="${tests.dir}"/>
- <load-config filename="${flex.config}" />
- <library-path dir="${flex.lib}" append="true">
- <include name="flex.swc" />
- </library-path>
- <library-path dir="${libs.dir}" append="true">
- <include name="*.swc" />
- </library-path>
- </mxmlc>
-
- <exec executable="open" os="Mac OS X">
- <arg line='-a "flash player" ${tests.output}' />
- </exec>
-
- </target>
-</project>
View
@@ -13,7 +13,9 @@ tests.dir=${basedir}/tests
libs.dir=${basedir}/libs
output.dir=${basedir}/bin
docs.dir=${basedir}/docs
+report.dir=${basedir}/report
output.swc=${output.dir}/${project.name.versioned}.swc
+tests.swf=${output.dir}/AS3SignalsTestRunner.swf
# Project links
as3signals.project.link=http://github.com/robertpenner/as3-signals
View
@@ -6,8 +6,10 @@
<!-- Copy Flex SDK location from environment variable. This can be set manually instead. -->
<property name="FLEX_HOME" value="${env.FLEX_HOME}" />
<property file="build.properties"/>
+
+ <taskdef resource="flexUnitTasks.tasks" classpath="${libs.dir}/flexUnitTasks.jar" />
- <target name="swc" depends="" description="Compile AS3 code into a SWC">
+ <target name="swc" depends="" description="Compile AS3 code into a SWC.">
<echo>Using Flex SDK at: ${FLEX_HOME}</echo>
<java jar="${FLEX_HOME}/lib/compc.jar" dir="." fork="true" failonerror="true">
@@ -27,6 +29,68 @@
</target>
+ <target name="test" depends="swc" description="Run unit tests in a Flash Player window.">
+ <echo>[test] Running Unit Tests</echo>
+ <!-- Compile SWF -->
+ <java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
+ <arg value="${tests.dir}/${package.dir}/AllTestsRunner.as"/>
+ <arg value="-incremental=true"/>
+ <arg value="-source-path+=${src.dir}"/>
+ <arg value="-source-path+=${tests.dir}"/>
+ <arg value="-output=${tests.swf}"/>
+ <arg value="-target-player=10"/>
+ <arg value="-default-size=1000,800"/>
+ <arg value="-default-background-color=0x000000"/>
+ <arg value="-static-link-runtime-shared-libraries=true"/>
+ <!-- Include classes from SWCs in this folder, but only the ones we use. -->
+ <arg value="-library-path+=${libs.dir}"/>
+ <arg value="-verbose-stacktraces=true"/>
+ <arg value="-headless-server=true"/>
+ <arg value="-keep-as3-metadata+=Test,Suite,Before,BeforeClass,After,AfterClass,RunWith,Ignore,Inject"/>
+ </java>
+ <exec executable="open" os="Mac OS X">
+ <arg line='-a "flash player" ${tests.swf}' />
+ </exec>
+ <exec executable="cmd.exe" osfamily="windows">
+ <arg line='/C start ${tests.swf}' />
+ </exec>
+ </target>
+
+ <target name="ci" depends="swc" description="Run unit tests and create JUnit-style reports for continuous integration.">
+ <echo>[ci] Running Unit Tests</echo>
+ <delete dir="${report.dir}" quiet="true"/>
+ <mkdir dir="${report.dir}"/>
+
+ <!-- Compile SWF -->
+ <java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
+ <arg value="${tests.dir}/${package.dir}/AllTestsCIRunner.as"/>
+ <arg value="-incremental=true"/>
+ <arg value="-source-path+=${src.dir}"/>
+ <arg value="-source-path+=${tests.dir}"/>
+ <arg value="-output=${tests.swf}"/>
+ <arg value="-target-player=10"/>
+ <arg value="-default-size=1000,800"/>
+ <arg value="-default-background-color=0x000000"/>
+ <arg value="-static-link-runtime-shared-libraries=true"/>
+ <!-- Include classes from SWCs in this folder, but only the ones we use. -->
+ <arg value="-library-path+=${libs.dir}"/>
+ <arg value="-verbose-stacktraces=true"/>
+ <arg value="-headless-server=true"/>
+ <arg value="-keep-as3-metadata+=Test,Suite,Before,BeforeClass,After,AfterClass,RunWith,Ignore,Inject"/>
+ </java>
+
+ <!-- Execute test runner SWF and publish reports -->
+ <flexunit swf="${tests.swf}" toDir="${report.dir}" haltonfailure="false" verbose="true" localTrusted="false" />
+
+ <!-- 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>
+
<target name="clean-asdoc">
<delete dir="${docs.dir}" failOnError="false" includeEmptyDirs="true"/>
<mkdir dir="${docs.dir}"/>
View
Binary file not shown.
@@ -0,0 +1,20 @@
+package org.osflash.signals
+{
+ import asunit.core.FlexUnitCICore;
+ import asunit.core.TextCore;
+
+ import flash.display.MovieClip;
+
+ [SWF(width='1000', height='800', backgroundColor='#333333', frameRate='31')]
+ public class AllTestsCIRunner extends MovieClip
+ {
+ private var core:TextCore;
+
+ public function AllTestsCIRunner()
+ {
+ core = new FlexUnitCICore();
+ core.start(AllTests, null, this);
+ }
+ }
+}
+

0 comments on commit ce49004

Please sign in to comment.