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

# expect(_:_:sourceLocation:)

Check that an expectation has passed after a condition has been evaluated.

```
@freestanding(expression) macro expect(_ condition: Bool, _ comment: @autoclosure () -> Comment? = nil, sourceLocation: SourceLocation = #_sourceLocation)
```

## Parameters

`condition`

The condition to be evaluated.

`comment`

A comment describing the expectation.

`sourceLocation`

The source location to which recorded expectations and
issues should be attributed.

## Overview

If `condition` evaluates to `false`, an [`Issue`](/documentation/Testing/Issue) is recorded for the test
that is running in the current task.

---

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)