๐ 2019.11.16 (ํ )
WWDC 2015 | Session : 406 | Category : Testing
๐ UI Testing in Xcode - WWDC 2015 - Videos - Apple Developer
UI testing
Find and interact with UI elements Validate UI properties and state
UI recording Test reports
Core Technologies = XCTest + Accessibility
- Test case subclasses
- Test methods
- Assertions
- Integrate with Xcode
- CI via Xcode Server and xcodebuild
- Swift and Objective-C
์ฅ์ ๊ฐ ์๋ ์ฌ๋๋ค๋ ์ฑ์์ ๋ชจ๋ ์ฌ๋์ด ๋ฐ๋ ๋๊ฐ์ ๊ฒฝํ์ ํ ์ ์๊ฒ ํด์ฃผ๋ ๊ธฐ์
- Rich semantic data about UI
- UIKit and AppKit integration
- APIs for fine tuning
- UI test interact with the app the way a user does
UI testing depends on new OS feature
- iOS 9, OS X 10.11
Privacy protection
- iOS devices
- Enabled for development
- Connected to a trusted host running Xcode
- OS X must grant permission to Xcode Helper
- Prompted on first run
UI tests have special requirement
- Execute in a separate process
- Permission to use Accessibility
New Xcode target templates
- Cocoa Touch UI Testing Bundle(iOS)
- Cocoa UI Testing Bundle(OS X)
"Target to be Tested" setting
Three new classes
XCUIApplication
XCUIElement
XCUIElementQuery
Interact with your app
Recording generates the code
- Create new tests
- Expand existing tests
Proxy for tested application
- Tests run in a separate process (์ฑ์ ๋ผ์ดํ ์ฌ์ดํด๊ณผ ๋ ๋ฆฝ์ )
Launch Launch ์ ํญ์ ์๋ก์ด ํ๋ก์ธ์ค๋ฅผ ๋ถ๋ฌ์จ๋ค
- Always spawns a new process
- Implicitly terminates any preexisting instance
Starting point for finding elements
Proxy for element in application XCUIApplication์ฒ๋ผ ์ฑ์ proxy ์ญํ ์ ํ์ง๋ง element๋ ํ ์คํธ ์ฑ์ user interface element ์ญํ ์ด๋ค.
Types
- Button, Cell, Window, etc.
Identifiers
- Accessibility identifier, label, title, etc.
Most elements are found by combining types and identifier
Every XCUIElement is backed by a query
Query must resolve to exactly one match
- No matches or multiple matches cause test failure
- Failure raised when element resolves query
Exception
exists
property
- Simulate user interaction on elements
- APIs are platform-specific
button.click()
button.tap()
textField.typeText("Hello, World!")
API for specifying elements
Queries resolve collections of accessible elements Accessibility ์๊ฒ ๋ณด์ด๋ element๋ง ์ฐพ์ ์ ์๋ค
-
Number of matches:
count
-
Specify by identifier: subscripting
-
Specify by index:
elementAtIndex()
Accessibility data์ ์ง์ด ์ข์ ์๋ก ํ ์คํธ๋ฅผ ์์ฑ ํ๋ ๊ฒ์ด ์ฝ๊ณ ๋ ์ ๋ขฐ ํ ์ ์๋ค.