---
title: "expect(_:_:sourceLocation:)"
framework: testing
role: symbol
role_heading: Macro
path: "testing/expect(_:_:sourcelocation:)"
---

# expect(_:_:sourceLocation:)

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

## Declaration

```swift
@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.

## Mentioned in

Describing and reflecting values Testing for errors in Swift code Migrating a test from XCTest

## Overview

Overview If condition evaluates to false, an Issue is recorded for the test that is running in the current task.

## See Also

### Checking expectations

- [require(_:_:sourceLocation:)](testing/require(_:_:sourcelocation:)-5l63q.md)
- [require(_:_:sourceLocation:)](testing/require(_:_:sourcelocation:)-6w9oo.md)
