1

I'm adding some unit tests into my project and want to test that a method will accept nil as block parameter and not crash when it then attempts to execute the block. The unit test I've created so far is:

- (void) testNilBlock
{
    NSTimeInterval timeDelay = 0.2f;

    [self.objectBlockTest performBlock:nil
                            afterDelay:timeDelay];

    //Assert for non-exception
}

But I can't work out how to test for the exception with the built in time delay.

wibosco
  • 967
  • 1
  • 11
  • 32
  • possible duplicate of [Testing asynchronous call in unit test in iOS](http://stackoverflow.com/questions/15609219/testing-asynchronous-call-in-unit-test-in-ios) – Wain Feb 10 '14 at 15:19
  • @wain its a similar question but in this instance, I don't have the block to check "inside" for the async callback but rather I'm looking for a way to check a possible async exception – wibosco Feb 10 '14 at 15:23
  • Asynchronous testing is hard. Preferably, change your code to make it more testable, or run the run loop for a duration based on the time delay. – Wain Feb 10 '14 at 15:29

0 Answers0