您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源單元測(cè)試工具 > TestNG
使用ReportNG替換TestNG的默認(rèn)報(bào)告
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2016/1/7 14:10:00 ] 推薦標(biāo)簽:單元測(cè)試工具 軟件測(cè)試

  關(guān)于reportng的官網(wǎng)介紹:http://reportng.uncommons.org/
  1.下載reportNG的jar包:http://pan.baidu.com/s/1hq5znLU
  2.reprotNG的源碼:https://github.com/dwdyer/reportng
  3.在項(xiàng)目中導(dǎo)入reportNG的jar包
  4.更改eclipse設(shè)置
  5.設(shè)置完成后,運(yùn)行項(xiàng)目,在項(xiàng)目test-output/html/index.html即可查看report
  6.設(shè)置reportng的編碼

  更改源文件的AbstractReporter.java,并替換相應(yīng)jar包的class
protected void generateFile(File file,
String templateName,
VelocityContext context) throws Exception
{
//Writer writer = new BufferedWriter(new FileWriter(file));
//encoding to utf-8
OutputStream out=new FileOutputStream(file);
Writer writer=new BufferedWriter(new OutputStreamWriter(out,"utf-8"));
try
{
Velocity.mergeTemplate(classpathPrefix + templateName,
ENCODING,
context,
writer);
writer.flush();
}
finally
{
writer.close();
}
}
  7.更改報(bào)告的方法排列順序,按照方法的執(zhí)行先后順序來(lái)進(jìn)行排序的
  更改TestResultComparator.java,并替換相應(yīng)jar包的class
public int compare(ITestResult result1, ITestResult result2)
{
//return result1.getName().compareTo(result2.getName());
int longresult2 = 0;
if(result1.getStartMillis()<result2.getStartMillis()) {
longresult2 = -1;
}else {
longresult2 = 1;
}
return longresult2;
}

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