---
title: TestScoping
framework: testing
role: symbol
role_heading: Protocol
path: testing/testscoping
---

# TestScoping

A protocol that tells the test runner to run custom code before or after it runs a test suite or test function.

## Declaration

```swift
protocol TestScoping : Sendable
```

## Overview

Overview Provide custom scope for tests by implementing the scopeProvider(for:testCase:) method, returning a type that conforms to this protocol. Create a custom scope to consolidate common set-up and tear-down logic for tests which have similar needs, which allows each test function to focus on the unique aspects of its test.

## Topics

### Instance Methods

- [provideScope(for:testCase:performing:)](testing/testscoping/providescope(for:testcase:performing:).md)

## Relationships

### Inherits From

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

### Conforming Types

- [IssueHandlingTrait](testing/issuehandlingtrait.md)
- [ParallelizationTrait](testing/parallelizationtrait.md)

## See Also

### Creating custom traits

- [Trait](testing/trait.md)
- [TestTrait](testing/testtrait.md)
- [SuiteTrait](testing/suitetrait.md)
