<junit printsummary="yes" haltonfailure="no">
<classpath>
<path refid="classpath"/>
<pathelement location="${dist.junit}"/>
</classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${doc.junitReport}">
<fileset dir="${dist.junit}" includes="**/*Test.class" />
</batchtest>
</junit>
<junitreport todir="${doc.junitReport}">
<fileset dir="${doc.junitReport}">
<include name="TEST*-*.xml"/>
</fileset>
<report format="frames" styledir="${junit.styleDir}" todir="${doc.junitReport}"/>
</junitreport>
junit的使用并不很難,然而要書寫一個好的TestCase卻并非易事。一個不好的TestCase往往是既浪費了時間,也起不了實際的作用。相反,一個好的TestCase,不僅可以很好的指出代碼中存在的問題,而且也可以作為代碼更準確的文檔,同時還在持續集成的過程中起非常重要的作用。在此給出書寫TestCase時需要注意的幾點: