+ All Categories
Home > Documents > 移动App 测试 教学探讨 - mooctest.org ·...

移动App 测试 教学探讨 - mooctest.org ·...

Date post: 26-May-2020
Category:
Upload: others
View: 53 times
Download: 0 times
Share this document with a friend
26
2017/8/19 1 移动App 测试 教学探讨 朱少民 同济大学软件学院 Kerryzhu @tongji.edu.cn 移动App的发展 2
Transcript
Page 1: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

1

移动App

测试教学探讨

朱少民同济大学软件学院

[email protected]

移动App的发展2

Page 2: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

2

移动app的特点

移动应用特点

Android/iOS native &

Web View 混合

更新很快

对用户体验要求高

网络连接不稳定

降低流量

降低功耗

……

Page 3: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

3

移动应用软件测试

兼容性测

交互性测试

用户体验测试

耗电量测试

网络流量测试

网络连接测试

性能测试

稳定性测试

移动应用测试个人/团体赛

脚本开发

测试用例设计

发现App中Bug++

(个人赛只有这项)自动评分

eclipse的插件自动计算Activity、控件对象的测

试覆盖率

1)测试设计(50%):结构合理、思路清晰,最高给15分;每个有效用例给3

分,最多35分2)缺陷报告(50%) :清晰、描述清楚,最高给10分; 每个有效Bug 给3分,用户体验bug给1~2分,最多40分

Page 4: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

4

移动应用测试个人/团体赛

Appium脚本开发(有单独培训课程)

Page 5: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

5

移动App测试设计

测试分析是测试设计的基础: 明确测试范围、列出被测试的界面、功能、场景、业务规则、业务数据;

测试设计思路:功能层次图、业务流程图、正面/负面测试、思维导图;

功能测试、性能测试、安全性测试等

设计方法:等价类划分、边界值分析、决策表…基于场景的测试、端到端的测试;

覆盖度: 代码、功能、状态、控制流、数据流;

用例描述:名称/目的、前提/条件、数据、操作、期望结果;

数据驱动的测试用例……

Bug的发现和报告

测试思维训练:分析性思维、情景性思维、创造性思维(逆向、发散性思维等)

Bug发现能力的培养:探索式测试、上下文驱动、了解技术、了解开发、观察力、聚焦与发散、。

测试用例助一臂之力,也是用例的作用

Bug的有效性:test oracle,测试依据

Bug描述:期望 vs. 实际结果、屏幕拷贝

/trace Log

Page 6: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

6

移动应用测试的主要内容

移动App功能测试

专项测试

性能测试

移动App“闪退”的测试

安全性测试

用户体验测试

移动App功能测试

面向接口的自动化测试

Android App UI自动化测试

iOS App UI自动化测试

跨平台的App UI自动化测试

Page 7: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

7

面向接口的自动化测试

基于HTTP协议的接口

web service接口,如XML-RPC、

JSON-RPC、SOAP、REST等

REST-assured

Android App UI自动化测试

Robotium (native/web)

Espresso

UIAutomator

MonkeyRunner (Android SDK tool)

Selendroid (native)

Robolectric(web)

LessPainful

ATAF

TestComplete

Page 8: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

8

Robotium

支持对native和WebView 的操作

能自动的支持多个安卓Activities;

有单独的录制回放工具

可以和Maven、Gradle、Ant等工

具进行集成

https://github.com/RobotiumTech/robotium

Android 平台上类似 Selenium 的集成测试工具,能够对各种控件进

行操作,模拟各种手势操作、查找和断言机制的API

Robotium 脚本示例

Page 9: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

9

Espresso 与UI Automator

AndroidJUnitRunner: 与 JUnit 4兼容的android测试执行

Espresso: 面向单个app 的功能UI测试自动化框架

UI Automator: 跨多个app、跨系统和app的功能UI测试自动化框架

https://code.google.com/p/android-test-kit/

Espresso是由Google开源的一套面向android移动应用UI的自动化测

试框架,现在已经融入android整个Testing Support Library之中,构

成官方完整的自动化测试解决方案

Espresso 与UI Automatorhttps://developer.android.com/tools/testing-support-library/index.html

Espresso 可以写出类似JUnit那样更美观的自动化测试脚本,可充分利用

被测app所实现的程序代码,而且能够实现UI 线程同步,解决了可能存

在的并发问题,能够改进测试的可靠性。

View matching(ViewMachers):为View 构建的、灵活的API,

借助onView方法来定位UI layout view,且支持多层次view的定位。

Action APIs (ViewActions):一系列扩展的、以完成UI交互操

作API集,即借助ViewInteraction.perform方法来完成view的操作。

ViewAssertions: 借助ViewInteraction.check方法来判定当前所选定

view的状态,以完成测试所需的验证。

Page 10: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

10

Espresso 脚本示例

http://developer.android.

com/reference/android/s

upport/test/espresso/pack

age-summary.html

UI Automator代码示例

Page 11: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

11

iOS App UI自动化测试

Instruments

instruments的主界面

Page 12: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

12

使用instruments录制脚本

使用Accessibility Inspector识别对象

Page 13: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

13

借助logElementTree获得UI元素信息

var target = UIATarget.localTarget();

var app = target.frontMostApp();

var window = app.mainWindow();

target.logElementTree();

在Automation中执行下列脚本

其它iOS自动化测试工具

Frank/Cucumber(https://github.com/TestingWithFrank/Frank ):一款基于

BDD(行为驱动开发)开发模式的iOS app测试工具,使用

Cucumber作为自然语言来编写结构化文字类型的验收测试用例,

适合模拟用户操作对应用程序进行黑盒测试。

KIF(Keep It Functional,https://github.com/kif-framework/KIF):Square公司专

为iOS设计、基于iOS accessibility实现的、面向UI的自动化测试

工具……

Kiwi(https://github.com/kiwi-bdd/Kiwi/):也是基于BDD的iOS测试框架,

遵守RSpec脚本规范,具有多层次的嵌套式上下文……

Page 14: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

14

跨平台的App UI自动化测试

Calabash /Cucumber: http://calaba.sh/

Appium: http://appium.io/

MonkeyTalk:https://www.cloudmonkeymobile.com/monkeytalk

Nativedriver:https://code.google.com/p/nativedriver/

Soasta TouchTest:http://www.soasta.com/touchtest/

Ranorex Studio: http://www.ranorex.com/mobile-automation-testing.html

Borland SilkMobile: http://www.borland.com/Products/Software-Testing/Automated-

Testing/Silk-Mobile

Experitest SeeTest: https://experitest.com/automation/

示例https://github.com/calabash/calabash-ios

https://github.com/calabash/calabash-android

Page 15: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

15

几款工具比较

专项测试:Android耗电量测试GSam Battery Monitor Pro

Page 16: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

16

专项测试: iOS耗电量测试

Energy Dialogistics

专项测试: iOS耗电量测试

Energy Dialogistics

Page 17: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

17

专项测试: Android app流量测试方法http://developer.android.com/reference/android/net/TrafficStats.html

proc/uid_stat/{UID} /tcp_snd (通过tcp协议发送的数据)

proc/uid_stat/{UID} /tcp_rcv (通过tcp协议接收的数据)

static long getMobileRxBytes() //收到的字节总数,不含WiFi

static long getMobileRxPackets() //获取Mobile连接收到的数据包总数

static long getMobileTxBytes() //Mobile发送的总字节数

static long getMobileTxPackets() //Mobile发送的总数据包数

static long getTotalRxBytes() //获取总的接受字节数,包含Mobile和WiFi等

static long getTotalTxBytes() //总的发送字节数,包含Mobile和WiFi等

static long getUidRxBytes(int uid) //获取某个网络UID的接受字节数

static long getUidTxBytes(int uid) //获取某个网络UID的发送字节数

专项测试: iOS流量测试方法

Page 18: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

18

移动App性能测试

web前端的性能测试

后台服务器性能测试

移动App端native性能测试

Fiddler

Yslow

FireBug

WebPageTest

Android内存分析

iOS内存分析

Android内存分析 DDMS

Page 19: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

19

Android内存分析

命令:adb shell top -h

iOS内存分析 Activity Monitor

Page 20: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

20

iOS内存分析 Leaks

Leaks显示内存分配情况和发现内存泄露问题

移动App“闪退”测试

Page 21: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

21

“闪退”测试的重点

网络连接突然断了、连接不稳定

网络弱连接,网络连接带宽不够,造成某些操作响应不及时

不同网络间的切换,如Wi-Fi切换到3G连接

离线情况下的操作

连接数量过多

交互性操作,同时打开有冲突的应用

不支持多指操作的App,用户做了多指操作

用户过快连续多次点击

操作点正好处在边界上

屏幕横竖翻转

安全性测试

Page 22: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

22

Top 10 Mobile app 安全性风险

M1: Weak Server Side Controls

M2: Insecure Data Storage

M3: Insufficient Transport Layer Protection

M4: Unintended Data Leakage

M5: Poor Authorization and Authentication

M6: Broken Cryptography

M7: Client Side Injection

M8: Security Decisions Via Untrusted Inputs

M9: Improper Session Handling

M10: Lack of Binary Protections

安全性测试 OWASP Mobile Security Projecthttps://www.owasp.org/index.php/OWASP_Mobile_Security_Project

Page 23: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

23

安全性测试 Mobile App Security Testing Guide

https://www.owasp.org/index.php/OWASP_Mobile_Security_Testing_Guide#tab=Main

OWASP Mobile Application Security Verification Standard (MASVS)

https://rawgit.com/OWASP/owasp-mstg/master/Generated/OWASP-MSTG-Table-of-Contents.html

移动app安全性测试工具15 Mobile Security Tools

https://codifiedsecurity.com/owasp-mobile-top-10/

Page 24: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

24

用户体验测试

按用户分类进行测试

A/B测试

众测

……

http://www.aliued.cn/2010/09/27/ab-testing-realization-method.html

https://www.nngroup.com/articles/mobile-usability-testing/

用户体验测试

https://www.usertesting.com/product/mobile-application-testing

17 Testing Tools for Mobile UX

Eight Lessons in Mobile Usability Testing

Page 25: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

25

教材

课外参考资料

Page 26: 移动App 测试 教学探讨 - mooctest.org · Espresso是由Google开源的一套面向android移动应用UI的自动化测 试框架,现在已经融入android整个Testing Support

2017/8/19

26

云课堂

Q & A


Recommended