IOS UI Automation Test Framework – Earl Grey
Winter Hung
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
Yahoo 奇摩超級商城 APP
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
Yahoo 奇摩超級商城 APP
■unit test 執行時間 : 10 min■YQL 執行時間 : 15 min■Smoke Test 執行時間 : 25 min■Functional Test 執行時間 : 53 min■Test Suite
■ Kiwi ■ TestNG■ UIAutomation
5
Yahoo 奇摩超級商城 APP
■Framework Advantange■ UI Test speed up■ Developer can be help ■ Code can’t complex ■ Synchronizing■ Result are consistent and reliable
6
Meet Earl Grey
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
Yahoo 奇摩超級商城 APP
■Features■ Synchronization■ User-like interactions ■ Visibility checks before interactions
9
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
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
Yahoo 奇摩超級商城 APP
■Selection■Format
selectElementWithMatcher(<GREYMatcher>)
■GREYMatcher grey_accessibilityID(“服飾” )
■Example [[EarlGrey selectElementWithMatcher:grey_accessibilityID(“服飾” )]]
12
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
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
Yahoo 奇摩超級商城 APP
■Assertions■Format
selectElementWithMatcher(<GREYMatcher>) assertWithMatcher(<GREYAction>)
■Example [[EarlGrey selectElementWithMatcher:grey_buttonTitle(@"略過,前往下一步 ")]
assertWithMatcher:grey_sufficientlyVisible()];
15
Yahoo 奇摩超級商城 APP
■Making Accessibility■ Accessibility Inspector choose Xcode → Open Developer Tool → Accessibility Inspector
16
Yahoo 奇摩超級商城 APP
■Making Accessibility■ Accessibility Enable
17
Setup EarlGrey to ECStore
Yahoo 奇摩超級商城 APP
■Setup Test Target In the Add Target window, select iOS → Test → iOS Unit Testing Bundle: (include unit test)
19
Yahoo 奇摩超級商城 APP
■Setup Test Target
20
Yahoo 奇摩超級商城 APP
■Manage Schemes Product → Scheme → Manage Schemes
21
Yahoo 奇摩超級商城 APP
■Running pod install
22
Yahoo 奇摩超級商城 APP
■Running pod install
23
Yahoo 奇摩超級商城 APP
■Running your test case
24
DEMO :
超級商城 APP TEST
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
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
Yahoo 奇摩超級商城 APP
■References■ EarlGrey official
http://google.github.io/EarlGrey/
■ EarlGrey github https://github.com/google/EarlGrey
28
29
Top Related