Run AsUnit runner from Ant
How can you run AsUnit test runner from Ant?
I'm on the Mac OS so I use:
open -a "flash 开发者_Go百科player" tests.swf
How can I make this cross platform?
Here's a target that will compile the tests into a swf and run them. The tests are run using the exec task. This version uses the open command from the Mac OS.
For Windows I can only think of using a property set to the complete path to the Flash player exe and using that to run the tests.
<target name="tests">
<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="${tests.dir}"/>
<load-config filename="${flex.config}" />
<library-path dir="${flex.lib}" append="true">
<include name="flex.swc" />
</library-path>
<library-path dir="${libs.test.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>
Here's the properties:
# Build locations
src.dir=${basedir}/src/main/actionscript
package.dir=your/apps/package
libs.dir=${basedir}/libs
output.dir=${basedir}/bin
output.swc=${output.dir}/${project.name.versioned}.swc
# testing
tests.dir=${basedir}/src/test/actionscript
tests.output=${output.dir}/${ant.project.name}-tests.swf
libs.test.dir=${basedir}/src/test/libs
test.main=test.main=${tests.dir}/${package.dir}/AllTestsRunner.as
docs.dir=${basedir}/docs
# flex resources
flex.config=${FLEX_HOME}/frameworks/flex-config.xml
flex.lib=${FLEX_HOME}/frameworks/libs
flextask.jar=${FLEX_HOME}/ant/lib/flexTasks.jar
mxmlc.jar=${FLEX_HOME}/lib/mxmlc.jar
compc.jar=${FLEX_HOME}/lib/compc.jar
精彩评论