Xcode 9
UI Testing

Multi-App Testing

XCUIApplication()
XCUIApplication(bundleIdentifier: "")
  • Extensions
  • App Groups

Not just your own apps...

XCUIApplication(bundleIdentifier: "com.apple.Preferences")
XCTest toggle network conditioner

Improved Querying

XCTest Queries

Queries find elements

Queries use Accessibility Data

Test requests a snapshot

App captures/serializes snapshot

App sends data back to test

Skip the Snapshot

Order of Magnitude Faster

Eliminates Memory Spikes Completely

First Match

Removes non-unique query protection

app.buttons.firstMatch
app.buttons["Done"].firstMatch
app.navigationBars.buttons["Done"].firstMatch

Test Reporting

Activities

Screenshots

& Attachments

PARALLEL

PARALLEL

PARALLEL

PARALLEL

PARALLEL

xcodebuild -scheme "tester" \
  -destination \
    'platform=iOS Simulator,name=iPhone X,OS=11.0' \
  -destination \
    'platform=iOS Simulator,name=iPhone 8,OS=11.0' \
  -destination \
    'platform=iOS Simulator,name=iPhone 7s,OS=11.0' \
  -destination \
    'platform=iOS Simulator,name=iPhone 7,OS=11.0' \
  -destination \
    'platform=iOS Simulator,name=iPhone 6s,OS=11.0' \
  -destination \
    'platform=iOS Simulator,name=iPhone 6,OS=11.0' \
build test

Headless Simulators

Xcode Server

  • Fastlane
  • xctool
  • BluePill
  • Jenkins, Travis, Circle

Async Testing

XCTestWaiter

Unfulfilled expectations do not automatically fail

XCTestWaiterResult

Fail with individual error messages

  • timeout
  • incorrectOrder

XCTestExpectation

  • XCTPredicateExpectation
  • XCTKVOExpectation
  • XCTNSNotificationExpectation

XCTestExpectation

  • Multiple Fulfillments
  • Inverted Behavior
  • Enforce Optional Order

XCUISiriService

Enable Siri on Simulator

Hardware   >   Siri

Branden's Head

@brandenbyers

brandenbyers.com

/slides/xcode-9-testing

example test files