您的位置:首页 > 移动开发 > Android开发

Android-Junit-Report测试报告生成——Android自动化测试学习历程

2015-05-17 17:09 609 查看
视频地址:
http://www.chuanke.com/v1983382-135467-384869.html
这个内容其实已经在用了,我在上一篇文章robotium—只有apk文件的测试中已经讲过这个内容了,并且自己也用Python+wxpython写了界面程序,来实现跑case+获取xml运行结果+xml转html+发送邮件的功能

主要内容:

一、测试需求

1、统计每个case的执行时间

2、哪些case成功、失败

3、失败的case给出log

4、产生网页html报告结果

二、环境部署

以robotium为例,需要的环境:

1、JDK1.7、Android开发环境

2、Robotium的jar包

3、android-junit-report.jar包

三、报告生成原理

去官网瞅瞅:http://zutubi.com/,通过点击open source可进入下载页面下载

quick start

For the impatient, here is an overview of how to integrate the runner with Ant builds. Note all modifications are made to your test project, i.e. the project which implements the JUnit tests:

Grab the jar from the downloads page and add it to your
libs/
directory.

Edit
AndroidManifest.xml
to set
android:name
in the
<instrumentation>
tag to:
com.zutubi.android.junitreport.JUnitReportTestRunner
.

Edit
ant.properties
to add the line:
test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner


Run your tests as you would normally:
$ ant debug install test


Pull the resulting XML report from the device (from the application under test's internal storage directory):
$ adb pull /data/data/<main app package>/files/junit-report.xml


Integrate the XML with your chosen build tool.

接下来就是原理:

1、com.zutubi.android.junitreport.JUnitReportTestRunner——具体见上面描述,需要修改的地方是两个,一个是instrumentation的tag,一个是Run As的Run Configuration,修改Instrumentation runner的值

2、调用机制:

三层封装:

Junit Report---》Robotium---》Instrumentation

四、脚本实现自动化后续收集工作

脚本1——运行testcase

脚本2——把xml从手机内存卡pull出来

脚本3——把xml转换成html

脚本4——把html的报告合并到手工、压力、性能报告中去

脚本5——发送邮件周知即可

Done!还是需要自己去写。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: