Skip to content

[feature request] Multiple expectations in waitUntil() #314

@d-lord

Description

@d-lord

When writing tests with multiple asynchronous components (eg using OHHTTPStubs), it would be nice to do this:

waitUntil { clientDone, serverDone in
    stub(alwaysIntercept()) { request in 
        serverDone() // server is satisfied that it received the request
        return OHHTTPStubsResponse(data: someResponse, statusCode: 200, headers: nil)
    }
    MyObj.doWithCallback { _ in
        clientDone() // client is satisfied that it received and handled the response
    }
}

At the moment, this doesn't seem to be possible at all, as nested waitUntils are explicitly caught: "Unexpected exception raised: Nested async expectations are not allowed to avoid creating flaky tests."

I'm enjoying using Nimble - it's much cleaner to write with than XCTest - but in this case, XCTest's expectations seem to be the better tool for the job.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions