Contents

XCTestCase

The primary class for defining test cases, test methods, and performance tests.

Declaration

class XCTestCase

Mentioned in

Overview

A test case is a group of related test methods, with optional setup and teardown before and after tests run. See Defining Test Cases and Test Methods for more information.

XCTestCase conforms to XCTActivity, so you can simplify complex tests by organizing them into activities, and attach output to tests for later analysis. For more information, see Activities and Attachments.

Create tests for asynchronous operations using expectations. For more information, see Testing Asynchronous Operations with Expectations. If your app uses Swift Concurrency, annotate test methods with async or async throws instead to test asynchronous operations, and use standard Swift concurrency patterns in your tests.

Create tests to measure performance for specific blocks of code using the methods in the Measuring Performance section below. Build performance tests as part of a continuous improvement cycle for performance in your app. For more information, see Improving your app’s performance.

Topics

Customizing Test Setup and Teardown

Managing Test Case Execution

Measuring Performance

Creating Asynchronous Test Expectations

Waiting for Expectations

Monitoring UI Interruptions

Creating Tests Programmatically

See Also

Test cases and test methods