[论文解读] From Manual Android Tests to Automated and Platform Independent Test Scripts
本文提出 BARISTA,一种工具,允许测试人员通过录制用户交互并使用直观界面视觉指定预期结果(即验证器),来创建与平台无关的自动化测试脚本。该技术利用 Android 的可访问性框架捕获操作和验证器,而无需修改应用程序,生成可兼容 Espresso 的测试脚本,可在多种设备和操作系统版本上可靠执行,其在可移植性和鲁棒性方面优于现有工具。
Because Mobile apps are extremely popular and often mission critical nowadays, companies invest a great deal of resources in testing the apps they provide to their customers. Testing is particularly important for Android apps, which must run on a multitude of devices and operating system versions. Unfortunately, as we confirmed in many interviews with quality assurance professionals, app testing is today a very human intensive, and therefore tedious and error prone, activity. To address this problem, and better support testing of Android apps, we propose a new technique that allows testers to easily create platform independent test scripts for an app and automatically run the generated test scripts on multiple devices and operating system versions. The technique does so without modifying the app under test or the runtime system, by (1) intercepting the interactions of the tester with the app and (2) providing the tester with an intuitive way to specify expected results that it then encode as test oracles. We implemented our technique in a tool named Barista and used the tool to evaluate the practical usefulness and applicability of our approach. Our results show that Barista can faithfully encode user defined test cases as test scripts with built-in oracles, generates test scripts that can run on multiple platforms, and can outperform a state-of-the-art tool with similar functionality. Barista and our experimental infrastructure are publicly available.
研究动机与目标
- 解决在碎片化设备和操作系统版本上进行手动 Android 应用测试时人力投入高且易出错的问题。
- 通过允许非开发人员通过交互方式创建测试脚本,减少测试自动化对专业编程技能的需求。
- 支持创建鲁棒且可复用的测试用例,其内置的验证器与特定的 UI 布局或设备配置无关。
- 实现生成的测试脚本在无需重新编码的情况下,自动在多个平台上执行。
- 通过使用 Espresso 等标准框架生成与平台无关的测试脚本,提升测试的可移植性和可维护性。
提出的方法
- 通过 Android 的可访问性框架录制用户对应用的交互,捕获触摸、输入和导航事件。
- 为测试人员提供可视化界面,通过选择 UI 元素并定义预期状态来指定预期结果(即验证器)。
- 使用 Espresso 测试框架格式,将记录的操作和指定的验证器编码为与平台无关的测试脚本。
- 将记录的执行轨迹转换为结构化测试代码,可在任何兼容 Android 版本的设备或模拟器上执行。
- 利用可访问性标识符和 UI 层次结构信息,确保测试脚本在不影响逻辑结构的轻微 UI 变更下依然稳健。
- 利用 Android 可访问性 API 拦截并记录交互,而无需修改应用程序或运行时系统。
实验结果
研究问题
- RQ1非程序员是否能够通过交互式录制和可视化验证器指定,创建出可靠且与平台无关的 Android 应用测试脚本?
- RQ2BARISTA 生成的测试脚本在不同设备和操作系统版本上的可移植性,与现有录制/回放工具相比如何?
- RQ3BARISTA 在多大程度上支持创建即使在轻微 UI 变更下依然有效的鲁棒验证器?
- RQ4BARISTA 在测试执行和脚本生成方面的性能,与最先进的工具(如 Espresso 或 UIAutomator)相比如何?
- RQ5BARISTA 生成的测试脚本是否能够有效用于应用更新后的回归测试?
主要发现
- BARISTA 成功将用户定义的测试用例及其验证器编码为可在多种设备和 Android 操作系统版本上执行的与平台无关的测试脚本。
- 与现有录制/回放工具相比,生成的测试脚本具有更高的可移植性,因其依赖语义化的 UI 标识符,而非屏幕坐标。
- 在测试脚本的可靠性与跨平台执行能力方面,BARISTA 表现优于具有类似功能的先进工具。
- 该工具使测试人员能够以极少的培训即可创建测试脚本,无需掌握编程或测试框架知识。
- 只要逻辑结构和可访问性标签保持不变,BARISTA 生成的测试脚本对轻微的 UI 变更(如元素重新定位)具有鲁棒性。
- 该方法支持“一次录制,处处运行”的原则,显著降低了回归测试的维护开销。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。