Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit ce49004116812341c70f09a296a603bcff66c891 1 parent 26142f7
Robert Penner robertpenner authored
7 build-asunit.properties
... ... @@ -1,7 +0,0 @@
1   -tests.output=${output.dir}/${ant.project.name}-tests.swf
2   -test.lib=${libs.dir}/asunit4-alpha.swc
3   -test.main=${tests.dir}/${package.dir}/AllTestsRunner.as
4   -
5   -flex.config=${FLEX_HOME}/frameworks/flex-config.xml
6   -flex.lib=${FLEX_HOME}/frameworks/libs
7   -flextask.jar=${FLEX_HOME}/ant/lib/flexTasks.jar
34 build-asunit.xml
... ... @@ -1,34 +0,0 @@
1   -<project name="as3-signals" basedir="." default="test">
2   -
3   - <!-- Set up a prefix for all environment variables. -->
4   - <property environment="env."/>
5   - <fail unless="env.FLEX_HOME" message="FLEX_HOME needs to be defined as an environment variable or in the Ant build." />
6   - <!-- Copy Flex SDK location from environment variable. This can be set manually instead. -->
7   - <property name="FLEX_HOME" value="${env.FLEX_HOME}" />
8   - <property file="build.properties"/>
9   - <property file="build-asunit.properties"/>
10   -
11   - <target name="test">
12   -
13   - <taskdef resource="flexTasks.tasks" classpath="${flextask.jar}" />
14   -
15   - <mxmlc file="${test.main}" output="${tests.output}"
16   - incremental="true" debug="false"
17   - static-link-runtime-shared-libraries="true">
18   - <source-path path-element="${src.dir}" />
19   - <source-path path-element="${tests.dir}"/>
20   - <load-config filename="${flex.config}" />
21   - <library-path dir="${flex.lib}" append="true">
22   - <include name="flex.swc" />
23   - </library-path>
24   - <library-path dir="${libs.dir}" append="true">
25   - <include name="*.swc" />
26   - </library-path>
27   - </mxmlc>
28   -
29   - <exec executable="open" os="Mac OS X">
30   - <arg line='-a "flash player" ${tests.output}' />
31   - </exec>
32   -
33   - </target>
34   -</project>
2  build.properties
@@ -13,7 +13,9 @@ tests.dir=${basedir}/tests
13 13 libs.dir=${basedir}/libs
14 14 output.dir=${basedir}/bin
15 15 docs.dir=${basedir}/docs
  16 +report.dir=${basedir}/report
16 17 output.swc=${output.dir}/${project.name.versioned}.swc
  18 +tests.swf=${output.dir}/AS3SignalsTestRunner.swf
17 19
18 20 # Project links
19 21 as3signals.project.link=http://github.com/robertpenner/as3-signals
66 build.xml
@@ -6,8 +6,10 @@
6 6 <!-- Copy Flex SDK location from environment variable. This can be set manually instead. -->
7 7 <property name="FLEX_HOME" value="${env.FLEX_HOME}" />
8 8 <property file="build.properties"/>
  9 +
  10 + <taskdef resource="flexUnitTasks.tasks" classpath="${libs.dir}/flexUnitTasks.jar" />
9 11
10   - <target name="swc" depends="" description="Compile AS3 code into a SWC">
  12 + <target name="swc" depends="" description="Compile AS3 code into a SWC.">
11 13 <echo>Using Flex SDK at: ${FLEX_HOME}</echo>
12 14
13 15 <java jar="${FLEX_HOME}/lib/compc.jar" dir="." fork="true" failonerror="true">
@@ -27,6 +29,68 @@
27 29
28 30 </target>
29 31
  32 + <target name="test" depends="swc" description="Run unit tests in a Flash Player window.">
  33 + <echo>[test] Running Unit Tests</echo>
  34 + <!-- Compile SWF -->
  35 + <java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
  36 + <arg value="${tests.dir}/${package.dir}/AllTestsRunner.as"/>
  37 + <arg value="-incremental=true"/>
  38 + <arg value="-source-path+=${src.dir}"/>
  39 + <arg value="-source-path+=${tests.dir}"/>
  40 + <arg value="-output=${tests.swf}"/>
  41 + <arg value="-target-player=10"/>
  42 + <arg value="-default-size=1000,800"/>
  43 + <arg value="-default-background-color=0x000000"/>
  44 + <arg value="-static-link-runtime-shared-libraries=true"/>
  45 + <!-- Include classes from SWCs in this folder, but only the ones we use. -->
  46 + <arg value="-library-path+=${libs.dir}"/>
  47 + <arg value="-verbose-stacktraces=true"/>
  48 + <arg value="-headless-server=true"/>
  49 + <arg value="-keep-as3-metadata+=Test,Suite,Before,BeforeClass,After,AfterClass,RunWith,Ignore,Inject"/>
  50 + </java>
  51 + <exec executable="open" os="Mac OS X">
  52 + <arg line='-a "flash player" ${tests.swf}' />
  53 + </exec>
  54 + <exec executable="cmd.exe" osfamily="windows">
  55 + <arg line='/C start ${tests.swf}' />
  56 + </exec>
  57 + </target>
  58 +
  59 + <target name="ci" depends="swc" description="Run unit tests and create JUnit-style reports for continuous integration.">
  60 + <echo>[ci] Running Unit Tests</echo>
  61 + <delete dir="${report.dir}" quiet="true"/>
  62 + <mkdir dir="${report.dir}"/>
  63 +
  64 + <!-- Compile SWF -->
  65 + <java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
  66 + <arg value="${tests.dir}/${package.dir}/AllTestsCIRunner.as"/>
  67 + <arg value="-incremental=true"/>
  68 + <arg value="-source-path+=${src.dir}"/>
  69 + <arg value="-source-path+=${tests.dir}"/>
  70 + <arg value="-output=${tests.swf}"/>
  71 + <arg value="-target-player=10"/>
  72 + <arg value="-default-size=1000,800"/>
  73 + <arg value="-default-background-color=0x000000"/>
  74 + <arg value="-static-link-runtime-shared-libraries=true"/>
  75 + <!-- Include classes from SWCs in this folder, but only the ones we use. -->
  76 + <arg value="-library-path+=${libs.dir}"/>
  77 + <arg value="-verbose-stacktraces=true"/>
  78 + <arg value="-headless-server=true"/>
  79 + <arg value="-keep-as3-metadata+=Test,Suite,Before,BeforeClass,After,AfterClass,RunWith,Ignore,Inject"/>
  80 + </java>
  81 +
  82 + <!-- Execute test runner SWF and publish reports -->
  83 + <flexunit swf="${tests.swf}" toDir="${report.dir}" haltonfailure="false" verbose="true" localTrusted="false" />
  84 +
  85 + <!-- Generate readable JUnit-style reports -->
  86 + <junitreport todir="${report.dir}">
  87 + <fileset dir="${report.dir}">
  88 + <include name="TEST-*.xml" />
  89 + </fileset>
  90 + <report format="frames" todir="${report.dir}/html" />
  91 + </junitreport>
  92 + </target>
  93 +
30 94 <target name="clean-asdoc">
31 95 <delete dir="${docs.dir}" failOnError="false" includeEmptyDirs="true"/>
32 96 <mkdir dir="${docs.dir}"/>
BIN  libs/flexUnitTasks.jar
Binary file not shown
20 tests/org/osflash/signals/AllTestsCIRunner.as
... ... @@ -0,0 +1,20 @@
  1 +package org.osflash.signals
  2 +{
  3 + import asunit.core.FlexUnitCICore;
  4 + import asunit.core.TextCore;
  5 +
  6 + import flash.display.MovieClip;
  7 +
  8 + [SWF(width='1000', height='800', backgroundColor='#333333', frameRate='31')]
  9 + public class AllTestsCIRunner extends MovieClip
  10 + {
  11 + private var core:TextCore;
  12 +
  13 + public function AllTestsCIRunner()
  14 + {
  15 + core = new FlexUnitCICore();
  16 + core.start(AllTests, null, this);
  17 + }
  18 + }
  19 +}
  20 +

0 comments on commit ce49004

Please sign in to comment.
Something went wrong with that request. Please try again.