1 / 23

淘宝 Android 自动化测试

淘宝 Android 自动化测试. 丁津津 ( 淘宝 · 冰阳 ). Merry Christmas. 目录. 目前淘宝 Android 客户端的 UI 自动化方案 实际使用中遇到的问题 计划 和想法. Android 自动化测试. TMTS (Taobao Mobile Test System) 定位:无线 UI 自动化测试框架 核心:基于 Instrumentation 特点:发布版测试、 WebView 支持 我们的实践 持续集成 发布流程 Open source at. 原始设计需求.

hayward
Download Presentation

淘宝 Android 自动化测试

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 淘宝Android自动化测试 丁津津 (淘宝·冰阳)

  2. Merry Christmas

  3. 目录 • 目前淘宝Android客户端的UI自动化方案 • 实际使用中遇到的问题 • 计划和想法

  4. Android自动化测试 • TMTS (Taobao Mobile Test System) • 定位:无线UI自动化测试框架 • 核心:基于Instrumentation • 特点:发布版测试、WebView支持 • 我们的实践 • 持续集成 • 发布流程 • Open source at

  5. 原始设计需求 • 支持对release版本的测试。即不需要为自动化测试专门打包。 • 支持敏捷开发和持续集成。每天自动打包,自动运行测试用例,给出测试报告。 • 支持内嵌WebView的自动化。淘宝有大量的应用有WebView的场景,需要自动化。 • 在应用退出时调用killProcess杀掉自已进程,不应影响自动化测试的结果收集。之前也用过Robotium框架,但由于淘宝应用的特殊性,导致自动化能运行,但最后的结果收集不到,除非把killProcess代码注释掉再编译。

  6. 方案选择 • Instrumentation • monkeyrunner • Monkey

  7. TMTS架构

  8. TmtsFramework • Finder: 返回TmtsView对象,TmtsDevice对象 • Device: 提供常见的对设备的操作,如功能按键的点击,屏幕方向的旋转 • Logger: 持久化存储测试过程中的日志

  9. TmtsFramework • View: 定义操作 • 基类,TmtsView • doClick() • doLongClick() • requestFocus() • TmtsTextView • setText(String) • String getText() • TmtsToast • String getText() • TmtsAbsListView • T getChildByIndex(int, Class<T>) • scrollToLine(int) • TmtsWebView • excuteJs(String) • String excuteJsAndReturn(String)

  10. TMTS示例 • 原生控件示例 • WebView示例

  11. 原生控件示例 public void testFindMixed() throws Exception { findTmtsTextViewByText("ListView").doClick(); TmtsAbsListView listView = findTmtsViewById("my_listview", TmtsAbsListView.class); TmtsViewGroup group = listView.getChildByIndex(20, TmtsViewGroup.class); TmtsTextView textView = group.getChildByIndex(1, TmtsTextView.class); assertEquals("Item20", textView.getText()); TmtsTextView textView2 = findTmtsTextViewByText("Item20"); assertEquals("Item20", textView2.getText()); group.doLongClick(); findTmtsTextViewByText("Item One").doClick(); assertEquals("1 pressed!", findTmtsToast().getText()); }

  12. WebView示例 public void testSearch() throws Exception { findTmtsTextViewByText("WebView").doClick(); TmtsWebViewwebview = findTmtsWebViewById("mywebview",TmtsWebView.class); webview.excuteJs ("document.getElementsByName('q')[0].value='iphone4s'"); webview.excuteJs ("document.getElementsByClassName('btn-bg')[0].click()"); String result = webview.excuteJsAndReturn("document.body.innerText"); assertTrue(result, result.contains("5580")); Thread.sleep(5000); • }

  13. 实践-持续集成 • Daily Build • Daily Run • Test Report

  14. 实践-发布流程管理

  15. TMTS的特性

  16. 反馈的主要问题

  17. 计划 • 完善WebView • 支持跨应用测试 • 减少编写测试代码的难度

  18. WebView • 移动平台上的应用越来越强调开发速度 • 利用WebView来展现使用HTML5编写的应用是今后Android应用发展的一个趋势 • 目前可以借鉴的是selenium中的方案

  19. 欢迎加入 • 如果您对Android/iOS/Windows phone系统感兴趣,想有深入的研究 • 如果您喜欢逆向思维 • 如果您对测试工具开发感兴趣 • 如果您喜欢研究优秀的开源代码 • 也欢迎加入TMTS开源社区:http://code.taobao.org/p/TMTS/wiki/index/ • 联系方式:taichan@taobao.com

  20. Thanks • 欢迎关注:淘宝测试自动化组 • 开源页面自动化框架:Automan • 开源无线自动化框架:TMTS

  21. Backup Slides

More Related