Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2020 Developer Tools

WWDC20 · 7 min · Developer Tools

XCTSkip your tests

Get the test results that matter — and skip the ones that don’t. Discover how you can implement XCTSkip to conditionally avoid tests at runtime. We’ll take you through how to return this new test result and better document tests beyond pass and fail within your test bundle. To get the most out of this session, you should be familiar with XCTest and unit/UI testing. Watch “Testing in Xcode” for a primer. Once you’ve learned about XCTSkip, learn more about improvements in testing: Watch "Triage test failures with XCTIssue", "Handle interruptions and alerts in UI tests", "Get your test results faster", and "Eliminate animation hitches with XCTest". To learn how to improve your testing suites, check out "Write tests to fail".

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 2 snippets

Use XCTSkipUnless to bypass a test on devices other than iPad swift · at 5:45 ↗
func testExample() throws {

    /// Example usage: skip test if device is not an iPad
    try XCTSkipUnless(UIDevice.current.userInterfaceIdiom == .pad, 
              "Pointer interaction tests are for iPad only")

    // test...
}
Use guard+XCTSkip to bypass a test on an older OS version swift · at 5:58 ↗
func testExample() throws {

    /// Example usage: skip test if OS version is older than iOS 13.4
    guard #available(iOS 13.4, *) else {
        throw XCTSkip("Pointer interaction tests can only run on iOS 13.4+")

    // test...
}