Ant 使用Junit自动测试要注意的问题

来源:互联网 发布:final cut pro 7 mac 编辑:程序博客网 时间:2024/06/01 09:01

在构建Ant自动测试的时候,必须要加入ant_home/lib下的库,要不会出现ClassNotFound的异常。

 

    <path id="test.classpath">
        
<fileset dir="${ant.library.dir}">
            
<include name="*.jar"/>
        
</fileset>
        
<pathelement location="${test.home}/classes"/>
    
</path>
    
<target name="test" depends="all">
        
<mkdir dir="${test.report}"/>
        
<mkdir dir="${test.home}/classes"/>
        
<javac srcdir="${test.home}/src"
               destdir
="${test.home}/classes"
               debug
="${compile.debug}"
               deprecation
="${compile.deprecation}"
               optimize
="${compile.optimize}">
            
<classpath refid="master-classpath"/>

        
</javac>

        
<junit printsummary="true"
               fork
="true"
               haltonfailure
="false"
               failureproperty
="tests.failed"
               showoutput
="true">
            
<classpath refid="test.classpath"/>
            
<classpath refid="master-classpath"/>
            
<formatter type="xml"/>
            
<batchtest todir="${test.report}">
                
<fileset dir="${test.home}/classes">
                    
<include name="**/*Test.*"/>
                
</fileset>
            
</batchtest>
        
</junit>
        
<junitreport todir="${test.report}">
            
<fileset dir="${test.report}">
                
<include name="TEST-*.xml"/>
            
</fileset>
            
<report format="frames" todir="${test.report}"/>
        
</junitreport>
        
<fail if="tests.failed">
            ---------------------------------------------------------
            One or more tests failed, check the report for detail...
            ---------------------------------------------------------
        
</fail>
    
</target>

 

原创粉丝点击