您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > junit
使用ant進(jìn)行junit,并生成report
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時間:[ 2014/1/13 11:03:17 ] 推薦標(biāo)簽:junit ant 測試 單元

一、Junit任務(wù)基本概念:

junit是ant的基本任務(wù)之一。這個任務(wù)運(yùn)行一個或多個JUNIT測試,并收集以一種或多種格式顯示結(jié)果。下面是幾個junit任務(wù)的屬性

1、haltonfailure,printsummary分別表示如果測試失敗是否中止,是否打印基本信息。

2、fommatter--收集結(jié)果數(shù)據(jù),一個或多個formatter可以直接在junit,test,或者batchtest下面嵌套使用。有以下三種formatter:

   brief:以文本格式提供測試失敗的詳細(xì)內(nèi)容。

   plain:以文本格式提供測試失敗的詳細(xì)內(nèi)容以及每個測試的運(yùn)行統(tǒng)計

   xml:以xml格式提供擴(kuò)展的詳細(xì)內(nèi)容,包括正在測試時ant的特性,系統(tǒng)輸出,以及每個測試用例的系統(tǒng)錯誤。 

   <formatter type="xml"/>將會在data目錄下為所有的測試用例都創(chuàng)建一個xml文件。

3、test

 運(yùn)行單獨的測試用例

  <test name=.../>

4、batchtest,同時運(yùn)行多個測試用例

  <formatter type="xml"/>

  <batchtest todir="">

   <fileset dir="" include=""/>

  </batchtest>

 測試的輸出結(jié)果將放到todir。而dir中所有的測試用例都將運(yùn)行。

  xml formatter的默認(rèn)命名規(guī)范為Test-*.xml.

5、syspropertyset,運(yùn)行junit test的時候,可以指定syspropertyset,這樣在Test*.java文件中可以通過System.getProperty();來獲取在構(gòu)建文件中定義的property的值。例子:

   <propertyset id="propertyset1">

     <propertyref name=$#@##/>

     <propertyref prefix="#%##$"/>

   </propertyset>

   <junit>

    ...

    <syspropertyset refid="propertyset1"/>

   </junit>

6、sysproperty,也可以在junit中定義sysproperty,所定義的property的用法和上面的syspropertyset中的property的用法是一樣的。

    <sysproperty name="" value=""/>

7、fork="true",讓junit運(yùn)行在獨立的jvm中。 ???

上一頁123下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd