關于reportng的官網介紹:http://reportng.uncommons.org/
1.下載reportNG的jar包:http://pan.baidu.com/s/1hq5znLU
2.reprotNG的源碼:https://github.com/dwdyer/reportng
3.在項目中導入reportNG的jar包
4.更改eclipse設置
5.設置完成后,運行項目,在項目test-output/html/index.html即可查看report
6.設置reportng的編碼
更改源文件的AbstractReporter.java,并替換相應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.更改報告的方法排列順序,按照方法的執(zhí)行先后順序來進行排序的
更改TestResultComparator.java,并替換相應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;
}