<!--
{
  "availability" : [
    "Xcode: 16.0.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "swift: 6.0.0 -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/Trait/prepare(for:)-4pe01",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift Testing",
      "Testing"
    ],
    "preciseIdentifier" : "s:7Testing5TraitPAAE7prepare3foryAA4TestV_tYaKF"
  },
  "title" : "prepare(for:)"
}
-->

# prepare(for:)

Prepare to run the test that has this trait.

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

## Parameters

`test`

The test that has this trait.

## Discussion> Throws: 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.

---

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)