Top Banner
IOS UI Automation Test Framework – Earl Grey Winter Hung
29

Ios ui automation test framework

Apr 21, 2017

Download

Engineering

Winter Hong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ios ui automation test framework

IOS UI Automation Test Framework – Earl Grey

Winter Hung

Page 2: Ios ui automation test framework

2

• Release IPhone 7 and IOS 10• Drop UIAutomation Template in Instruments 8.0Apple

• Smoke and Functional Test Refined • Performance Lab Refine• Monkey Test Refine• CD Pipeline Refine

Store

• Smoke and Functional Test Refined very important• Decision a UI Test FrameworkUITest

Page 3: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

Page 4: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■上線至今 3 年 ■APP 下載次數 : 100 多萬■Unit Test : 805 per■YQL Test : 102 per ■Smoke Test Cases : 50 per■Functional Test Cases : 500 ~ 600 per

4

Page 5: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■unit test 執行時間 : 10 min■YQL 執行時間 : 15 min■Smoke Test 執行時間 : 25 min■Functional Test 執行時間 : 53 min■Test Suite

■ Kiwi ■ TestNG■ UIAutomation

5

Page 6: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Framework Advantange■ UI Test speed up■ Developer can be help ■ Code can’t complex ■ Synchronizing■ Result are consistent and reliable

6

Page 7: Ios ui automation test framework

Meet Earl Grey

Page 8: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Earl Grey is an UI Automation Test Framework■ Enable you to write clear and concise tests■ Google internal UI Testing framework ■ Use in Youtube, Google Calendar

Google Photos, Google translate ■ Recently open sourced

8

Page 9: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Features■ Synchronization■ User-like interactions ■ Visibility checks before interactions

9

Page 10: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■How Earl Grey works■ EarlGrey runs in the same process at the app under test,

and has access to the same memory as the app■ User private methods to learn view

hierarchy and inject touches ■ Works in conjunction with the

XCTest Framework

10

Page 11: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Interaction APIs■ Selection API

Selecting an element to interact■ Action API

Performing an action on it■ Assertion API

Making an assertion to verify state

11

Page 12: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Selection■Format

selectElementWithMatcher(<GREYMatcher>)

■GREYMatcher grey_accessibilityID(“服飾” )

■Example [[EarlGrey selectElementWithMatcher:grey_accessibilityID(“服飾” )]]

12

Page 13: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Selection■A GREYMatcher compliant object can be ambiguous and

match elements■You can combine multiple GREYMatchers

grey_allOf() , grey_anyof() , grey_not()

■Example id <GREYMatcher> resultMatcher = grey_allOf(grey_accessibilityLabel(title), grey_accessibilityTrait(UIAccessibilityTraitButton), nil);

[EarlGrey selectElementWithMatcher:resultMatcher];

13

Page 14: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Action■Format

selectElementWithMatcher(<GREYMatcher>) performAction(<GREYAction>)

■You can combine multiple GREYMatchers grey_tap() , grey_loginPerss() , grey_tapAtPoint()

■Example [[EarlGrey selectElementWithMatcher:grey_buttonTitle(@"略過,前往下一步 ")] performAction:grey_tap()];

14

Page 15: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Assertions■Format

selectElementWithMatcher(<GREYMatcher>) assertWithMatcher(<GREYAction>)

■Example [[EarlGrey selectElementWithMatcher:grey_buttonTitle(@"略過,前往下一步 ")]

assertWithMatcher:grey_sufficientlyVisible()];

15

Page 16: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Making Accessibility■ Accessibility Inspector choose Xcode → Open Developer Tool → Accessibility Inspector

16

Page 17: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Making Accessibility■ Accessibility Enable

17

Page 18: Ios ui automation test framework

Setup EarlGrey to ECStore

Page 19: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Setup Test Target In the Add Target window, select iOS → Test → iOS Unit Testing Bundle: (include unit test)

19

Page 20: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Setup Test Target

20

Page 21: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Manage Schemes Product → Scheme → Manage Schemes

21

Page 22: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Running pod install

22

Page 23: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Running pod install

23

Page 24: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Running your test case

24

Page 25: Ios ui automation test framework

DEMO :

超級商城 APP TEST

Page 26: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Xcode build Command Linexcrun xcodebuild -workspace ECStoreApp.xcworkspace -scheme ECStoreAppUITests -configuration AutomationTest -destination "platform=iOS Simulator,OS=9.3,name=iPhone 6s" clean test

26

Page 27: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■Known Issues■ Can’t interact with system dialogs■ No 3D Touch support■ No deep link and universal link support■ No today widget and notification support

27

Page 28: Ios ui automation test framework

Yahoo 奇摩超級商城 APP

■References■ EarlGrey official

http://google.github.io/EarlGrey/

■ EarlGrey github https://github.com/google/EarlGrey

28

Page 29: Ios ui automation test framework

29