Webdriver+Testng自定义html测试报告


     testng自带的html测试报告不是很好用,打开慢,内容简单,基本不具备什么参考价值,所有想到自己重新定义一份html格式的报告,可以参考jsp转换成html页面的原理+testng监听器实现。


代码如下:

1.实现testng listener接口:

public class testReport implements ITestListener

2.实现ItestListener 接口的onStart方法:

public void onStart(ITestContext context) {
		File htmlReportDir = new File("test-output/html-report");
		if (!htmlReportDir.exists()) {
			htmlReportDir.mkdirs();
		}
		String reportName = String.valueOf(new Date().getTime())+".html";
		reportPath = htmlReportDir+"/"+reportName;
		File report = new File(htmlReportDir,reportName);
		if(report.exists()){
				try {
					report.createNewFile();
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
		String msg = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><meta name=\"author\" content=\"ec-qa:xin.wang\"><meta name=\"description\" content=\"自动化测试用例结果列表\"><title>UI自动化测试报告</title></head><body STYLE=\"background
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值