使用JUnit&Ant生成UT报表
1. JUnit Test Case测试类需要从TestCase类继承
2. Ant的配置文件如下,添加一个target用来run JUnit并生成报表
 <project default="report" basedir=".">
  	  <target name="runtests">
        <java fork="yes" classname="junit.textui.TestRunner"
            taskname="junit" failonerror="true">
            <arg value="unitTest.calculation.CalculationTest"/>
            <classpath>
                <pathelement location="Test.jar" />
                <pathelement path="" />
            </classpath>
        </java>
    </target>
    
    <target name="report">
     <junit printsummary="yes" fork="yes" haltonfailure="no" >
             <classpath>
                 <fileset dir="../">
                                        <include name="Test.jar"  />
                 	<include name="lib/test/hamcrest-core-1.1.jar"  />
                                 </fileset>
          </classpath>
                <formatter type="xml"/>
                <test name="unitTest.calculation.calculationTest" todir="../report" />
</junit>
<junitreport todir="../report/html">
  <fileset dir="../report">
    <include name="TEST-unitTest.calculation.calculationTest.xml"/>
  </fileset>
  <report format="frames" todir="../report/html"/>
</junitreport>
</target>
</project>
3. 执行Ant生成一个html形式的报表

                    
                
                
            
        
浙公网安备 33010602011771号