Hello ant1.7 and junit4
13
Dec
Dec
0
源起
現在慢慢習慣使用 Junit4 寫測試,發現目前 eclipse 3.2 支援的 ant 1.6.5 的 junit task 不支援 junit4,所以想試一下新的 ant1.7。
junit 4
除了 @Test 之外,目前測試 spring 的 bean 往往都是一次取得 application context 來測,這時候 @BeforeClass 也是很好用。
ant 1.7
目前是 RC 版,先下載 apache-ant-1.7.0RC1-bin.zip,解開為目錄。 然後開 eclipse 的 ant 設定,將其中的 Ant Home 換成 1.7 的目錄即可。
<target name="test" depends="compile">
<junit printsummary="yes">
<classpath refid="supportlib.classpath"/>
<formatter type="xml" />
<batchtest fork="yes" todir="${reports.tests}">
<fileset dir="${src.test}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="report" depends="test">
<junitreport todir="${reports}">
<fileset dir="${reports.tests}">
<include name="TEST-*.xml"/>
</fileset>
<report
format="frames" todir="${reports}/html"/>
</junitreport>
</target>
觀察
- 雖然 junit 3 的支援比較完整,不過新東西還是要試一下。