withIssueContext(fileID:filePath:line:column:operation:)
Sets the context for issues reported for the duration of the synchronous operation.
func withIssueContext<R>(fileID: StaticString, filePath: StaticString, line: UInt, column: UInt, operation: () throws -> R) rethrows -> R
Parameters
- fileID
The source
#fileID
to associate with issues reported during the operation.- filePath
The source
#filePath
to associate with issues reported during the operation.- line
The source
#line
to associate with issues reported during the operation.- column
The source
#column
to associate with issues reported during the operation.- operation
A synchronous operation.
This context will override the implicit context from the call sites of reportIssue(_:fileID:filePath:line:column:)
and withExpectedIssue(_:isIntermittent:fileID:filePath:line:column:_:)
, and can be leveraged by custom test helpers that want to associate reported issues with specific source code.
Overloads
func withIssueContext<R>(fileID: StaticString, filePath: StaticString, line: UInt, column: UInt, isolation: isolated (any Actor)?, operation: () async throws -> R
) async rethrows -> R Sets the context for issues reported for the duration of the asynchronous operation.