Search code examples
iosobjective-ctddxctest

Is there a way to “reject” a `XCTestExpectation`?


I would like to make sure that in one particular case a certain NSNotification is not sent. Is there an easy way to achieve this with XCTestCase?


Solution

  • Create a helper method to subscribe to the NSNotification. Upon receiving it, set a BOOL. Test against that BOOL's value (lack of being changed).