3 Star 7 Fork 1

凤凰院大白/cucumberReportCreate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
GPL-2.0

Cucumber Report Creater

这是一款可以集成到任何UI自动化测试框架的测试报告生成工具,界面样式完全照搬 Cucumber Report(可能是我比较喜欢绿色吧)。

如何使用

1、测试完成后,将你的报告数据组装成如下示例;
2、读取 webReport.xml 文件;
3、将重新组装的测试报告数据 json 序列化;
4、用 json 序列化后的数据替换读取的 webReport.xml 文件中的 #JSON_STRING__JSON_STRING#

测试报告数据说明

{
	"cases": [{                                                                  --- 用例数组 
		"finishTime": "2018-09-20 14:11:01",                                 --- 用例完成时间  
		"caseName": "NG_Login_001 使用工号登录业务系统",                       --- 用例名称  
		"status": "success",                                                 --- 用例状态success-成功  fail、error-失败  
		"steps": [{                                                          --- 测试步骤数组 
			"mark": "",                                                  --- 备注,验证结果、出错信息、输入内容等  
			"status": true,                                              --- 步骤结果 true-正常 其他-失败  
			"stepId": "1",                                               --- 步骤id,需要保证全局唯一  
			"stepName": "打开开发测试环境地址",                            --- 步骤名称  
			"testTime": "2018-09-20 14:11:01",                           --- 测试时间  
			"screenshot": "snapshot\\NG_Validate_Transaction_Status.png" --- 该步骤的截图,可为空  
		}]  
	}],  
	"browserName": "Chrome",                                                     --- 运行浏览器类型  
	"testTime": "2018-09-20 14:10:58",                                           --- 测试时间  
	"endTime": "2018-09-20 14:14:03",                                            --- 结束时间  
	"totalCount": 3,                                                             --- 用例总数  
	"successCount": 2,                                                           --- 成功数量  
	"title": "UI自动化测试报告"                                                   --- 报告标题  
}

示例代码

Java
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
String template = FileUtil.read("webReport.xml");
template = template.replaceFirst("#JSON_STRING__JSON_STRING#", gson.toJson(result));
output.write(template);
Python
file_object = open(path.join('./', 'webReport.xml'), encoding='utf-8')
try:
    file_context = file_object.read()
    file_context = file_context.replace('#JSON_STRING__JSON_STRING#', json.dumps(result))
    with open('xxxx.html', 'w', encoding='utf-8') as f:
      f.write(file_context)
finally:
    file_object.close()
Ruby
File.open("webReport.xml","r:utf-8") do |lines|
  buffer = lines.read.gsub('#JSON_STRING__JSON_STRING#', result.to_json)
  File.open("xxxxx.html","w"){|l|
    l.write(buffer)
  }
end

截图

截图

空文件

简介

cucumber样式UI自动化报告生成 展开 收起
README
GPL-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML/CSS
1
https://gitee.com/xuwangcheng/cucumberReportCreate.git
git@gitee.com:xuwangcheng/cucumberReportCreate.git
xuwangcheng
cucumberReportCreate
cucumberReportCreate
master

搜索帮助