2010-02-28 136 views

回答

1

這裏的目標是將測試編譯成swf並運行它們。測試使用exec任務運行。此版本使用來自Mac OS的打開命令。

對於Windows,我只能想到使用屬性設置爲Flash player exe的完整路徑並使用它來運行測試。

<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> 

這裏的屬性:

# 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