Contents

provideScope(for:testCase:performing:)

Runs the evaluation and makes its result available to the test body through an evaluation context.

Declaration

nonisolated(nonsending) func provideScope(for test: Test, testCase: Test.Case?, performing function: @Sendable () async throws -> Void) async throws

Parameters

  • test:

    The test to which this trait is attached.

  • testCase:

    The specific test case being run, or nil when running the whole test.

  • function:

    The test body closure to invoke after the evaluation completes.

Discussion

The Swift Testing framework calls this method automatically when you attach the trait to a test. The evaluation runs first, the framework stores its result in EvaluationContext, and then the test body executes inside that context.