Using OCMock, how do I test if a method does nothing?
- (void)myMethod:(BOOL)active
{
if (active) {
// Set property or do whatever
}
// Do nothing -- I need to test this scenario
}
You can create a partial mock to verify that the method is called. Then you have to devise a test that makes sure that the code inside the if statement isn't reached. How to do that depends entirely one what "// Set property or do whatever" does.
That said, if you have an if statement around the entire body of your method you might want to consider refactoring your code...