Testing asynchronous code on iOS with OCunit

前端 未结 2 1718
独厮守ぢ
独厮守ぢ 2020-12-14 13:13

Does anyone know of any existing library that allows testing asynchronous code with OCUnit? I\'m thinking about something like GHAsyncTestCase but that delivers

2条回答
  •  萌比男神i
    2020-12-14 13:28

    AGAsyncTestHelper takes a slightly different approach than AssertEventually since it is evaluating the expression rather than checking the pointer for new results. One advantage of using AGAsyncTestHelper is that it can be used for blocks, delegate-callbacks and whatnot.

    WAIT_WHILE(, );
    

    Answering the question

    id someObject = nil;
    [self doSomethingThatFetchesSomeObjectAsynchronously];
    WAIT_WHILE(self.someObject == nil, 1.0); 
    

提交回复
热议问题