使用ReportNG替换TestNG的默认报告

发表于:2016-1-07 11:19

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:R9527    来源:51Testing软件测试网采编

  关于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.更改报告的方法排列顺序,按照方法的执行先后顺序来进行排序的
  更改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;
}
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号