android UiAutomator修改UiAutomatorHelper生成测试报告
来源:互联网 发布:美甲软件 编辑:程序博客网 时间:2024/06/04 18:23
本人在学习UiAutomator的时候,发现UiAutomatorHelper快速调试类非常好用,最近想了一下利用UiAutomatorHelper类来生成一个测试报告,好得比那些乱七八糟的runlog好看多了。原理很简单,我就把我增加的代码贴出来好了。供大家参考,后期肯定好得做一些优化。
首先修改的是execCmd方法,其中在输出正确流的地方增加了一些判断。
while ((line = reader.readLine()) != null) {if (line.startsWith("INSTRUMENTATION_STATUS: test=")) {saveToFile("运行用例名称:"+getTest(line), "report.log", false);}if (line.startsWith("INSTRUMENTATION_STATUS: current")) {saveToFile("正在运行第"+getCurrent(line)+"个用例!", "report.log", false);}if (line.startsWith("INSTRUMENTATION_STATUS_CODE:")) {if (getCode(line).equalsIgnoreCase("-1")) {saveToFile("\n"+"---------------运行状态:运行错误!"+"\n", "report.log", false);}else if (getCode(line).equalsIgnoreCase("-2")) {saveToFile("\n"+"---------------运行状态:断言错误!"+"\n", "report.log", false);}else {saveToFile("运行状态:运行OK!", "report.log", false);}}System.out.println(line);saveToFile(line, "runlog.log", false);}
下面是一些提取有用信息的方法:
public String getTest(String text) {return text.substring(29, text.length());}public String getCode(String text) {return text.substring(29, text.length());}public StringgetCurrent(String text) {return text.substring(32, text.length());}public String getNow() {//获取当前时间Date time = new Date();SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String c = now.format(time);return c;}生成报告的样子有点粗糙:
用例运行开始2017-04-12 17:01:02
运行用例名称:testAddAndDeleteAdress
正在运行第1个用例!
运行状态:运行OK!
运行用例名称:testAddAndDeleteAdress
正在运行第1个用例!
---------------运行状态:运行错误!
运行用例名称:testBuyCourseByWechat
正在运行第2个用例!
运行状态:运行OK!
运行用例名称:testBuyCourseByWechat
正在运行第2个用例!
---------------运行状态:断言错误!
运行用例名称:testChatroom
正在运行第3个用例!
运行状态:运行OK!
运行用例名称:testChatroom
正在运行第3个用例!
---------------运行状态:运行错误!
运行用例名称:testLearnCornerAddQuestion
正在运行第4个用例!
运行状态:运行OK!
运行用例名称:testLearnCornerAddQuestion
正在运行第4个用例!
运行状态:运行OK!
运行用例名称:testVerifyGradeInScreenAndMyInfo
正在运行第5个用例!
运行状态:运行OK!
运行用例名称:testVerifyGradeInScreenAndMyInfo
正在运行第5个用例!
运行状态:运行OK!
- android UiAutomator修改UiAutomatorHelper生成测试报告
- android UiAutomator利用快速调试生成excel文档测试报告
- android UiAutomator利用快速调试生成html文档测试报告
- android UiAutomator生成测试报告的基本方法封装
- UiAutomatorHelper
- android UiAutomator如何把log、截图和测试报告放在一起
- UiAutomator 测试报告查看与分析
- android自动化测试之生成单元测试报告
- Android Studio 中生成测试报告(使用Robotium自动化测试)
- Android Studio查看测试覆盖率并生成测试报告
- android uiautomator
- Android uiautomator
- android UiAutomator一个完整的个人信息修改测试用例
- 测试报告的生成
- 使用JUNIT4 生成测试报告
- python+selenium 生成测试报告
- python+selenium 生成测试报告
- 测试报告生成 TestNG-xslt
- uploadfive详解
- 【cocos2dx】TMXTiledMap增加碰撞体
- 骄傲的代价
- sql优化思路整理
- View 绘制流程
- android UiAutomator修改UiAutomatorHelper生成测试报告
- maven常用命令
- RedHat终端下的快捷键
- 第十章:DOM(节点层次:Node类型和Document类型)
- 【敏捷开发每日一贴】用户故事规范、分解与拆分
- ADB 命令
- nginxredis zookeeper dubbo solr各自功能
- eclipse的ctrl+alt+向下键不能复制一行,原因是和快捷键冲突了
- 软件安装的练习