<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTContext",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTContext"
  },
  "title" : "XCTContext"
}
-->

# XCTContext

A proxy for the current testing context.

```
class XCTContext
```

## Overview

`XCTContext` provides a way for activities ([`XCTActivity`](/documentation/XCTest/XCTActivity)) to run against the current testing context, either directly in a test case or in custom testing utilities. You can break up long test methods in UI tests or integration tests into activities to reuse, and to simplify results in the Xcode test reports. Use [`runActivity(named:block:)`](/documentation/XCTest/XCTContext/runActivity(named:block:)) to run a block of code as a named substep in a test. For more information, see [Grouping Tests into Substeps with Activities](/documentation/XCTest/grouping-tests-into-substeps-with-activities).

## Topics

### Running Activities

[`runActivity(named:block:)`](/documentation/XCTest/XCTContext/runActivity(named:block:))

Creates and runs an activity with the provided block of code.

[`runActivityNamed:block:`](/documentation/XCTest/XCTContext/runActivityNamed:block:)

Creates and runs an activity with the provided block of code.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)