---
title: "withKnownIssue(_:isIntermittent:sourceLocation:_:)"
framework: testing
role: symbol
role_heading: Function
path: "testing/withknownissue(_:isintermittent:sourcelocation:_:)"
---

# withKnownIssue(_:isIntermittent:sourceLocation:_:)

Invoke a function that has a known issue that is expected to occur during its execution.

## Declaration

```swift
func withKnownIssue(_ comment: Comment? = nil, isIntermittent: Bool = false, sourceLocation: SourceLocation = #_sourceLocation, _ body: () throws -> Void)
```

## Parameters

- `comment`: An optional comment describing the known issue.
- `isIntermittent`: Whether or not the known issue occurs intermittently. If this argument is true and the known issue does not occur, no secondary issue is recorded.
- `sourceLocation`: The source location to which any recorded issues should be attributed.
- `body`: The function to invoke.

## Mentioned in

Migrating a test from XCTest

## Discussion

Discussion Use this function when a test is known to record one or more issues that should not cause the test to fail. For example: @Test func example() {   withKnownIssue {     try flakyCall()   } } Because all errors thrown by body are caught as known issues, this function is not throwing. If only some errors or issues are known to occur while others should continue to cause test failures, use withKnownIssue(_:isIntermittent:sourceLocation:_:when:matching:) instead.

## See Also

### Related Documentation

- [Known issues](testing/known-issues.md)

### Recording known issues in tests

- [withKnownIssue(_:isIntermittent:isolation:sourceLocation:_:)](testing/withknownissue(_:isintermittent:isolation:sourcelocation:_:).md)
- [withKnownIssue(_:isIntermittent:sourceLocation:_:when:matching:)](testing/withknownissue(_:isintermittent:sourcelocation:_:when:matching:).md)
- [withKnownIssue(_:isIntermittent:isolation:sourceLocation:_:when:matching:)](testing/withknownissue(_:isintermittent:isolation:sourcelocation:_:when:matching:).md)
- [KnownIssueMatcher](testing/knownissuematcher.md)
