配置FlexUnit 和Ant

      在Ant中调用FlexUnit,完成对Flex(AS)代码的测试。
      在http://weblogs.macromedia.com/pmartin/archives/2006/06/flexunit_ant.html中,Peter Martin已经为我们提供了FlexUnit的包以及例子
但是下载下来发现用不了,修改如下:
  
      1. 导入下载的工程FlexUnitExample,将FlexAntTasks.jar拷贝到ClassPath中,然后修改build.properties文件,增加basedir=".",修改
flex.unit.swf="${basedir}/bin/AntTestRunner.swf"
basedir="."
# General properties
output.dir
=${basedir}/dist

# Compile properties
#flex.sdk.home
=C:/apps/adobe/flex2.0/sdk
flex.sdk.home
=D:/Dev/Adobe/Flex Builder 3/sdks/3.0.0
application
=AntTestRunner.mxml
mxmlc.args
=-file-specs ${application} -library-path+=lib -output ${flex.unit.swf}

# Test properties
#flex.unit.swf
=${output.dir}/AntTestRunner.swf
flex.unit.swf
=${basedir}/bin/AntTestRunner.swf
report.dir
=${basedir}/report

  2.修改build.xml

<project name="FlexUnitExample" default="main">
        
    
<!-- Load the custom task definitions. -->
    
<taskdef
        resource
="com/adobe/ac/ant/tasks/tasks.properties" />

    
<!--
    
<taskdef
        resource
="com/adobe/ac/ant/tasks/tasks.properties"
        classpath
="${basedir}/FlexAntTasks.jar"/>
    
-->
    
    
<!-- Load the properties file. -->
    
<property file="build.properties" />
    
    
<target name="main" depends="compile, test" />
    
    
<target name="compile">
        
<exec
            dir
="${basedir}"
            executable
="${flex.sdk.home}/bin/mxmlc.exe"
            os
="Windows XP"
            failonerror
="false">
                            
            
<arg line="${mxmlc.args}" />
        
</exec>
        
        
<exec
            dir
="${basedir}"
            executable
="${flex.sdk.home}/bin/mxmlc"
            os
="Linux"
            failonerror
="false">
                                    
            
<arg line="${mxmlc.args}" />
        
</exec>
    
</target>
    
    
<target name="test">                        
        
<flexunit
            timeout
="0"
            swf
="${flex.unit.swf}"
            toDir
="${report.dir}"
            haltonfailure
="false" />
                
        
<junitreport todir="${report.dir}">
            
<fileset dir="${report.dir}">
                
<include name="TEST-*.xml"/>
              
</fileset>
                
              
<report format="frames" todir="${report.dir}/html"/>
        
</junitreport>
    
</target>
</project>
  
    3. 运行ant,就可以了,还是很方便的。





posted on 2008-06-27 15:05 想飞就飞 阅读(1079) 评论(2)  编辑  收藏 所属分类: Flex

评论

# re: 配置FlexUnit 和Ant 2008-07-24 15:10 Ramon

I didn't delve into so much about this automate test, I just download ANT script run the script with readme, but failed. With your suggestion it's work, and very cool, many thanks, excellent job.  回复  更多评论   

# re: 配置FlexUnit 和Ant 2009-08-11 00:47 bowen wang

Hi,

i got an error when i run this ant script. It stopped at:
[flexunit] opened server socket

BUILD FAILED
/home....../build.xml:26:Error launching the test runner.

Any idea? do you manage to run it on your computer successfully?  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

公告


导航

<2008年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

统计

常用链接

留言簿(13)

我参与的团队

随笔分类(69)

随笔档案(68)

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜