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

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

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

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

## 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:

```swift
@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:)`](/documentation/Testing/withKnownIssue(_:isIntermittent:sourceLocation:_:when:matching:))
instead.

## See Also

[Known issues](/documentation/Testing/known-issues)

Mark issues as known when running tests.



---

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)