---
title: Trait
framework: testing
role: symbol
role_heading: Protocol
path: testing/trait
---

# Trait

A protocol describing traits that can be added to a test function or to a test suite.

## Declaration

```swift
protocol Trait : Sendable
```

## Overview

Overview The testing library defines a number of traits that can be added to test functions and to test suites. Define your own traits by creating types that conform to TestTrait or SuiteTrait: You can add a trait that conforms to both TestTrait and SuiteTrait to test functions and test suites.

## Topics

### Enabling and disabling tests

- [enabled(if:_:sourceLocation:)](testing/trait/enabled(if:_:sourcelocation:).md)
- [enabled(_:sourceLocation:_:)](testing/trait/enabled(_:sourcelocation:_:).md)
- [disabled(_:sourceLocation:)](testing/trait/disabled(_:sourcelocation:).md)
- [disabled(if:_:sourceLocation:)](testing/trait/disabled(if:_:sourcelocation:).md)
- [disabled(_:sourceLocation:_:)](testing/trait/disabled(_:sourcelocation:_:).md)

### Controlling how tests are run

- [timeLimit(_:)](testing/trait/timelimit(_:).md)
- [serialized](testing/trait/serialized.md)

### Categorizing tests and adding information

- [tags(_:)](testing/trait/tags(_:).md)
- [comments](testing/trait/comments.md)

### Associating bugs

- [bug(_:_:)](testing/trait/bug(_:_:).md)
- [bug(_:id:_:)](testing/trait/bug(_:id:_:)-10yf5.md)
- [bug(_:id:_:)](testing/trait/bug(_:id:_:)-3vtpl.md)

### Running code before and after a test or suite

- [TestScoping](testing/testscoping.md)
- [scopeProvider(for:testCase:)](testing/trait/scopeprovider(for:testcase:).md)
- [TestScopeProvider](testing/trait/testscopeprovider.md)
- [prepare(for:)](testing/trait/prepare(for:).md)

### Type Methods

- [compactMapIssues(_:)](testing/trait/compactmapissues(_:).md)
- [filterIssues(_:)](testing/trait/filterissues(_:).md)

## Relationships

### Inherits From

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

### Inherited By

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

### Conforming Types

- [Bug](testing/bug.md)
- [Comment](testing/comment.md)
- [ConditionTrait](testing/conditiontrait.md)
- [IssueHandlingTrait](testing/issuehandlingtrait.md)
- [ParallelizationTrait](testing/parallelizationtrait.md)
- [Tag.List](testing/tag/list.md)
- [TimeLimitTrait](testing/timelimittrait.md)

## See Also

### Creating custom traits

- [TestTrait](testing/testtrait.md)
- [SuiteTrait](testing/suitetrait.md)
- [TestScoping](testing/testscoping.md)
