jonreid / OCMockito

Mockito for Objective-C: creation, verification and stubbing of mock objects
MIT License
991 stars 118 forks source link

Is there a way to assert method throws? #150

Closed nrudnyk closed 5 years ago

nrudnyk commented 6 years ago

would be nice to be able to do something like below:

[verify(<#methodCall#>) willThrow:<#(nonnull NSException *)#>]

does that make any sense?

jonreid commented 5 years ago

This can be done on an actual thrown exception with OCHamcrest:

assertThat(^{ /* method call */ }, throwsException(hasProperty(@"reason", @"Button not found")));

I don't see how a mock object would come into the picture.