runActivity(named:block:)
Creates and runs an activity with the provided block of code.
Declaration
@MainActor @preconcurrency class func runActivity<Result>(named name: String, block: @MainActor (any XCTActivity) throws -> Result) rethrows -> ResultParameters
- name:
A descriptive name for the activity, for display in Xcode’s test results browser.
- block:
A block of code for the test to execute as the body of the activity.
Return Value
A Result object that indicates whether the block of code runs successfully or encounters an error.
Discussion
Run a block of code as a named substep in a test. For more information, see Grouping Tests into Substeps with Activities.
To save screenshots or other test-result data for later investigation, call the add(_:) method on the instance of XCTActivity that the test system passes to your block. For more information, see Adding Attachments to Tests, Activities, and Issues.