
曹羽中 等:一种基于录制/重放的 Android 应用众包测试方法
2509
5
(Nanjing Institute of Software Technology, Insti tute of Software, Chinese Academy of Sciences, Nanjing 211169, Ch ina)
Abstra ct : It is well known that the fragmentation of Android ecosystem has caused severe compatibility issu es. Th er efore, for Android
apps, cross-platform testing (the apps must be t ested on a multitude of devi ces and operating system versions) is particularly important to
assure their quality. Although lots of cross-platform testing techniques have been proposed, there are still some limitations: 1) It is
time-consuming and error-prone to encode platform-agnostic tests manually; 2) Test scripts generated b y existing record/r eplay techniques
are brittle and will crash when replayed on different platforms; 3) Developers, and ev en test vendors have not equipped with some spe cial
Android devices; 4) Due to the lack of specific domain knowledge, the existing test methods cannot generate effective user inputs,
resulting in low testing coverage. As a result, apps that have not been fully tested, will lead to man y compatibility issues after releasing.
To address these limitations, this study proposes AppCheck, a crowdsourced testing service for Android apps. To generate tests that will
explore different behavior of the app automatically, AppCheck crowdsources event trace collection over the Internet, and various touch
events will be capt ured when re al us ers int eract with the app . The coll ected event traces are t hen tr ansfo rmed into dev ice- independent test
scripts, and directly replayed on the d evices of r eal us ers. During th e r eplay, various dat a (e.g., screenshots and layout in formation) will be
extracted to identify compatibility issues. The empirical evaluation shows that the proposed AppCheck is effective and improves
limitations of the state-of-th e-art.
Key words: Android; crowdsourced testing; fragmentation; automated t est; r ecording; r eplay
随着移动互联网技术的发展,未来互联网重心从传统的个人电脑转移到了新一代移动设备上,智能手机开
始被广泛使用.我们的日常生活,如购物、银行和旅行等活动都离不开手机应用程序.特别是 Google 公司推出移
动智能设备操作系统 Android 之后,各大主流手机制造商大规模地推出 Android 智能手机,Android 设备种类从
2014 年的 18 796
[1]
增长到 2015 年的 24 093
[2]
.在 2017 年 Google I/O 大会上,谷歌宣布,每月活跃安卓设备数量
超过 20 亿
[3]
.由于 Android 系统版本更迭频繁,同时为了吸引用户并在竞争中保持优势,不同的设备厂商会对
Android 系统进行定制,从而导致 Android 生态系统的碎片化.碎片化现象给 Android 应用的测试带来了巨大挑
战,应用开发者需要在多种不同类型、不同版本设备上进行大量重复机械的测试工作,Android 应用的自动化测
试技术因此成为研究热点.
在学术界,虽然目前已有很多针对 An droi d 应用的自动化测试技术和工具
[4−6]
,然而根据最近的实证研究
[7]
,
这些技术的测试覆盖率仍然很低.这是因为大量的应用程序是为具备特定领域知识用户开发的,如果不具备这
些领域知识,将无法触发某些特定的交互场景.在工业界,已有多种 Androi d 应用自动化测试框架被广泛使用,如
Android Espresso
[8]
,Robotium
[9]
,UIAutomator
[10]
,Appium
[11]
等.这些框架可以跨设备自动执行测试用例(A ppiu m
甚至支持测试 Hybrid App).但是不足在于,需要测试人员掌握特定的编程语言,并且手工编码会消耗测试人员大
量的精力.
用户交互行为录制/重放是一种常见的 Android 应用测试方法
[12,13]
.测试人员通过记录收集用户与被测应
用的交互事件序列,并在不同设备进行重放,以验证被测应用的功能与规约是否一致
[14]
.这种方式可以用于
Android 应用的兼容性测试,实现测试成本的降低和测试效率的提升
[15,16]
.现有的录制/重放技术
[12]
利用 Android
底层接口获取系统日志,进而形成测试脚本,具有不侵入应用内部、可以描述多应用交互等优点,但得到的原生
事件流脚本接近于机器码,不便于测试人员进行编辑修改;并且生成的测试脚本难以实现跨设备重放,缺乏重用
性.尽管相关工作尝试采用成线性比例缩放机制实现跨设备屏幕尺寸和分辨率的适配
[13]
,但方法适用性非常有
限,当应用的界面布局随着屏幕旋转或屏幕尺寸、分辨率发生变化后,该方法会失效.这导致生成的测试脚本却
不够健壮,在其他测试设备平台上运行时会崩溃.
区别于传统的 GUI 程序测试,Android 生态系统的碎片化要求应用需要在不同类型、不同版本的 Android
设备上进行测试,以保障应用的健壮性.但是在当前 Android 设备快速更新升级的情况下,应用开发者甚至专业
的测试厂商
[17]
都不可能购买所有需要测试的 Android 设备.为了解决这一问题,众多测试厂商(如 uTest
[18]
和
Testin
[19]
)使用了一个新兴的技术——众包测试
[20]
来测试移动应用.在众包测试中,拥有不同移动设备和使用环
境的真实用户测试同一应用软件.如发现 B ug,用户将根据 Bug 的严重程度得到奖励.然而,这样的过程仍然需要
大量繁琐的手工工作,同时,用户报告的 Bug 质量得不到保证
[21]
.通常情况下,Bug 在开发人员和用户之间多次沟
评论