Vincent Tourraine

Notes WWDC 2020 : Tests

#dev #iOS

Voici mes notes pour les sessions dédiées aux tests de la WWDC 2020.

Write tests to fail

Set up

Test: actions

Test: assertions

Tear down

Triage test failures with XCTIssue

New in Xcode 12

Swift errors in tests

Source locations for thrown errors, with Swift runtime improvements (iOS 13.4, macOS 10.15.4)

Throwing from setup and teardown with setUpWithError() throws and tearDownWithError() throws

Rich failure objects

In Xcode 12, errors are represented with XCTIssue: can now add attachments, and more.

XCTSkip your tests

New in Xcode 11.4

func testABC() throws {
  guard #available(iOS 13.4, *) else {
    throws XCTSkip("Can only run on iOS 13.4+")

  try XCTSkipIf(UIDevice.current.userInterfaceIdiom != .pad, "for iPad only")