自动化生成html报告


package Utils; import java.io.File;
import java.util.Date; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.log4j.Logger;
import org.testng.Reporter; public class ReportUtils { private static Logger logger = Logger.getLogger(ReportUtils.class.getName()); public ReportUtils() {
System.setProperty("org.uncommons.reportng.escape-output", "false");
} /*********************************************************************************************
* 写log和报告操作
*********************************************************************************************/
/**
* 写日志和报告
*
* @param comm
*/
public void log(String... comm) {
String time = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
if (comm.length == 0) {
Reporter.log("[" + time + "] <br />");
logger.info("");
} else {
Reporter.log("[" + time + "] " + comm[0] + "<br />");
logger.info(comm[0]);
}
} /**
* 写日志和报告
*
* @param comm
* @comment 如果selenium.properties中【isPrintDebugMsg】值为0,则只打印looger,不打印report
*/
public void debug(String... comm) {
if (1 == 1) {
log("[debug]" + comm[0]);
} else {
logger.info(comm[0]);
}
} /**
* 写错误日志和报告
*
* @param comm
*/
public void error(String comm) {
String time = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
Reporter.log("<span style=\"color:#FF0000\"><b>[" + time + "] [ERROR] " + comm + "</b></span><br />");
logger.error(comm);
} /**
* 写警告日志和报告
*
* @param comm
*/
public void warn(String comm) {
String time = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
Reporter.log("<span style=\"color:#FF7F27\"><b>[" + time + "] [WARNING] " + comm + "</b></span><br />");
logger.warn(comm);
} /**
* 写重要的日志和报告
*
* @param comm
*/
public void highLight(String comm) {
log("<span style='background-color:#FFE500;'>" + comm + "</span>");
} /**
* 写绿色高亮的的日志和报告
*
* @param comm
*/
public void greenLight(String comm) {
log("<span style='background-color:#CFFFBA;'>" + comm + "</span>");
} /**
* 参数高亮
*
* @param comm
*/
public void paraLight(String comm) {
if (1 == 1) {
log("<span style='background-color:#E4FFD9;'>" + comm + "</span>");
} else {
logger.info(comm);
}
} /**
* 给MCDB用的日志和报告
*
* @param comm
*/
public void mcdbLight(String comm) {
if (1 == 1) {
log("<span style='background-color:#C1E7F7;'>[MCDB]" + comm + "</span>");
} else {
logger.info("[MCDB]" + comm);
}
} /**
* 写醒目的标题
*
* @param comm
*/
public void title(String comm) {
String str;
str = "<p style=\"color:#0068BD;margin-top:25px;margin-bottom:8px\"><b>";
str = str + "**********************************************************************************************<br>";
str = str + "* " + comm + "<br>";
str = str + "**********************************************************************************************</b>";
str = str + "</p>";
Reporter.log(str);
} /**
* 用于截图的log写入
*
* @param comm
* @param file
*/
public void screenShotLog(String comm, File file) {
int width = 350;
String absolute = "file:" + file.getAbsolutePath(); Reporter.log("<a target='_blank' href=\"" + absolute + "\">");
Reporter.log("<img width=\"" + width + "\" src=\"" + absolute + "\" /> " + comm);
Reporter.log("</a><br />");
}
}
自动化生成html报告的更多相关文章
- 利用Python半自动化生成Nessus报告
0x01 前言 Nessus是一个功能强大而又易于使用的远程安全扫描器,Nessus对个人用户是免费的,只需要在官方网站上填邮箱,立马就能收到注册号了,对应商业用户是收费的.当然,个人用户是有16个I ...
- python+requests+excel+unittest+ddt接口自动化数据驱动并生成html报告(二)
可以参考 python+requests接口自动化完整项目设计源码(一)https://www.cnblogs.com/111testing/p/9612671.html 原文地址https://ww ...
- python+requests+excel+unittest+ddt接口自动化数据驱动并生成html报告(已弃用)
前言 1.环境准备: python3.6 requests xlrd openpyxl HTMLTestRunner_api 2.目前实现的功能: 封装requests请求方法 在excel填写接口请 ...
- [自动化]基于kolla-ansible部署的openstack自动化巡检生成xlsx报告
自动化巡检介绍 此巡检项目在kolla-ansible部署的openstack环境上开发,利用ansible-playbook编排的功能,对巡检的任务进行编排和数据处理.主要巡检的对象有IaaS平台和 ...
- [自动化]基于kolla部署的openstack自动化巡检生成xlsx报告
自动化巡检介绍 此巡检项目在kolla-ansible部署的openstack环境上开发,利用ansible-playbook编排的功能,对巡检的任务进行编排和数据处理.主要巡检的对象有IaaS平台和 ...
- python+requests+excel+unittest+ddt接口自动化数据驱动并生成html报告
1.环境准备: python3.6 requests xlrd openpyxl HTMLTestRunner_api 2.目前实现的功能: 封装requests请求方法 在excel填写接口请求参数 ...
- unittest同时支持参数化和生成html报告
最近在用python3.6+unittest+requests做自动化接口测试.发现一个问题,unittest中使用第3方插件parameterized进行参数化,再生成html报告时,运行就会失败. ...
- pytest文档13-allure2生成html报告(史上最详细)
前言 allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 1. ...
- pytest十五:pytest-html 生成 html 报告
pytest-HTML 是一个插件,pytest 用于生成测试结果的 HTML 报告.兼容 Python 2.7,3.6 pytest-html1.github 上源码地址[https://githu ...
随机推荐
- 深度学习开源库tiny-dnn的使用(MNIST)
tiny-dnn是一个基于DNN的深度学习开源库,它的License是BSD 3-Clause.之前名字是tiny-cnn是基于CNN的,tiny-dnn与tiny-cnn相关又增加了些新层.此开源库 ...
- 人脸识别引擎SeetaFaceEngine中Alignment模块使用的测试代码
人脸识别引擎SeetaFaceEngine中Alignment模块用于检测人脸关键点,包括5个点,两个眼的中心.鼻尖.两个嘴角,以下是测试代码: int test_alignment() { std: ...
- html学习第一天
由于之后想做个网站,所以web前端的也要学习一下. 昨天看了一下html,今天做一下记录. 首先是安装工具,用文本编辑器有点麻烦,我选择的是强大的 Dreamweaver CS6,不过大家喜欢文本编辑 ...
- 查看Linux系统版本的命令
1.lsb_release -a,即可列出所有版本信息: [root@S-CentOS ~]# lsb_release -a LSB Version: :base-4.0-amd64:base-4.0 ...
- R小问题
步骤 > library(xlsx) > test<-read.csv("I:/山农大学大数据中心/柱状图/z7.csv") > data1=test[] ...
- K-means算法实现
目录 K-means K-means x = xlsread("D:\MatlabData\西瓜数据集.xlsx"); m = length(x); [Idx,C]=kmeans( ...
- 785. Is Graph Bipartite?
Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipart ...
- Tree - XGBoost with parameter description
In the previous post, we talk about a very popular Boosting algorithm - Gradient Boosting Decision T ...
- curl常用用法
-v显示请求详细信息 curl www.baidu.com -v -X 指定请求方式 GET请求 curl -X GET http://localhost:8080/search?data=123 # ...
- BZOJ 1559 JSOI2009 密码 状压dp+AC自动机+搜索
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1559 分析: 这个题意真的是很**啊!!!直接说每一个字符串至少出现一次不就好了吗... ...