Skip to content

Difficult to debug fatal error when expectation is called after a test completes #500

Closed as not planned
@stephencelis

Description

@stephencelis

Description

If you are testing code that runs in a Task and forget to wait for it to finish, Swift Testing currently crashes.

Expected behavior

Ideally, Swift Testing wouldn't crash, and would instead emit a test failure or some other friendlier diagnostic.

Actual behavior

Swift Testing crashes with the message:

❌ Fatal error: Internal inconsistency: No test reporter for test case argumentIDs: Optional([])

Steps to reproduce

@Test func task() async {
  let task = Task {
    #expect(1 == 2)
  }
  // await task.value  // Comment in for a passing test
}

swift-testing version/commit hash

Testing Library Version: 75.7 (arm64e-apple-macos13.0) (Xcode 16 beta 1)

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
Target: arm64-apple-macosx14.0
Darwin Stephens-M2-Pro.lan 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug🪲 Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions