Skip to content

Support async calls with XCTAssertNoThrow, XCTAssertThrowsError, XCTExpectFailure... #419

Open
@Gray-Wind

Description

@Gray-Wind

Hello,

I'm trying to use XCTAssertNoThrow method with async function. I'm trying to use it as this:

        XCTAssertNoThrow {
            let item = try await map.getItem(with: "āž$*")
            XCTAssertNil(item)
        }

It turns out the callback is never run. In my case try returns with an error, which is thrown from getItem.

I ended up with this solution, which is suboptimal:

        var caughtError: Error?
        do {
            let item = try await map.getItem(with: "āž$*")
            XCTAssertNil(item)
        } catch {
            caughtError = error
        }
        XCTExpectFailure("test fails for the time being") {
            XCTAssertNil(caughtError)
        }

Side note: XCTExpectFailure doesn't run the async closure as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions