Menu

Waitforexpectationswithtimeout error

3 Comments

Error works fine when the asynchronous task ends before the timeout. But if the task takes longer than the timeout, things get more complicated. Unfortunately, calling the fulfill method after the timeout has expired crashes the test suite with this error:. Of course I can check if the test is finished before calling the fulfill method like this:. But this seems overly complicated and makes the test much harder to read. Am I missing something? Is there a simpler way to solve this problem? Yes, there is a much simpler way to avoid this API violation issue: Although not clearly documented, the expectation will be released when the timeout expires. So if the task takes longer than the timeout, the expectation variable will be nil when the task completion handler is called. Thus the fulfill method will be called on nil, doing nothing. I'm working on an OpenStack Swift Drive for OSX. When a folder is deleted locally with Finder, the deletion eventually propagates to the Server, I needed a test that waits for the server to be updated. To avoid the API violation crash, I've changed my expectations to be "weak waitforexpectationswithtimeout and changed the call to fulfill it to "zeroFoldersExpectation?. This fixed the crashes. Instead of creating expectation as weak variable as suggested in this answer I think you waitforexpectationswithtimeout also set is as block variable and nil it in completion handler of waitForExpectationsWithTimeout:. By posting your waitforexpectationswithtimeout, you agree to the privacy policy and terms of service. Stack Overflow Questions Jobs Documentation beta Tags Users. Sign up or log in to customize your list. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Waitforexpectationswithtimeout more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us. Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7. Join them; it only takes a minute: API violation - called -[XCTestExpectation fulfill] after the wait context has ended. What about when it is code uses MRC instead of ARC? Weak references are only supported error ARC so you will have to transition to ARC. With this approach I would worry that the expectation could get deallocated before you even get to use it, but I guess that's not happening if this is working for you. That's a REALLY helpful and make test readable than another block solution. Thanks 0xced that save me a lot of time. I came across the same problem but in my case I needed the Waitforexpectationswithtimeout version error the answer above. Jorge Costa 1 3. Instead of creating expectation as weak variable as suggested in this answer I think you could also set is error block variable and nil it in completion handler of waitForExpectationsWithTimeout: Piotr 5, 1 21 I think you also need to fail if the completionHandler is called back. XCTFail "should not be completed" and remove the rest of the code in the error. Yeah, you can do that. But the test should also fail automatically when the expectation is not fulfilled in time. I usually also print error to the console in completion handler. It will fail because the fulfill wasn't called. This is reliable and simple. With weak reference, I observed case that the expectation is not nullified after the timeout. It may depends on how the expectation is referenced in the code. No need to investigate relation of reference since just assign nil instead is fine. Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Stack Overflow works best with JavaScript enabled. MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3. Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

3 thoughts on “Waitforexpectationswithtimeout error”

  1. android_org says:

    Official Records of Riverside County, California, encumbering the.

  2. Agent says:

    In 2003, a squid with a mantle 2.5 meters long was captured near Antarctica.

  3. Alexander says:

    The production of fire directly or indirectly destroyed property and the image of the characters, Snopes and Pap.

Leave a Reply

Your email address will not be published. Required fields are marked *

inserted by FC2 system