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

# enabled(_:sourceLocation:_:)

Constructs a condition trait that disables a test if it returns `false`.

```
static func enabled(_ comment: Comment? = nil, sourceLocation: SourceLocation = #_sourceLocation, _ condition: @escaping @Sendable () async throws -> Bool) -> Self
```

## Parameters

`comment`

An optional comment that describes this trait.

`sourceLocation`

The source location of the trait.

`condition`

A closure that contains the trait’s custom condition logic.
If this closure returns `true`, the trait allows the test to run.
Otherwise, the testing library skips the test.

## Return Value

An instance of [`ConditionTrait`](/documentation/Testing/ConditionTrait) that evaluates the
closure you provide.

---

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)