Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gray-Wind opened this issue Sep 12, 2022 · 0 comments

Comments

@Gray-Wind
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants