---
title: "prepare(for:)"
framework: testing
role: symbol
role_heading: Instance Method
path: "testing/trait/prepare(for:)"
---

# prepare(for:)

Prepare to run the test that has this trait.

## Declaration

```swift
func prepare(for test: Test) async throws
```

## Parameters

- `test`: The test that has this trait.

## Discussion

Discussion note: Any error that prevents the test from running. If an error is thrown from this method, the test is skipped and the error is recorded as an Issue. The testing library calls this method after it discovers all tests and their traits, and before it begins to run any tests. Use this method to prepare necessary internal state, or to determine whether the test should run. The default implementation of this method does nothing.

## See Also

### 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)
