Class

XCTest

An abstract base class for creating, managing, and executing tests.

Declaration

class XCTest : NSObject

Overview

The XCTest class provides shared functionality used by XCTestCase and XCTestSuite for creating, managing, and executing tests. In most cases, you should subclass XCTestCase directly when defining tests in your project.

Topics

Test Properties

var name: String

The name of the test.

var testCaseCount: Int

The number of test cases in this test.

var testRun: XCTestRun?

The XCTestRun object that executed the test.

var testRunClass: AnyClass?

The XCTestRun subclass to instantiate when the test is run, to hold the test’s results.

Setup and Teardown

func setUp()

Provides an opportunity to reset state before each test method in a test case is called.

func tearDown()

Provides an opportunity to perform cleanup after each test method in a test case ends.

Running Tests

func perform(XCTestRun)

Executes a specific test.

func run()

Creates an instance of the class specified by testRunClass and passes it as a parameter to the perform(_:) method.

Relationships

Inherits From

Conforms To

See Also

Test Cases and Test Methods

Defining Test Cases and Test Methods

Add test cases and test methods to a test target to confirm that your code behaves as expected.

class XCTestCase

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