The method signatures are not defined by OCMock, they are the methods from the real classes, which means OCMock can't change the type from, say, int to NSValue. Also, in Objective-C you can't have two methods with the same name but different argument types, which means OCMock couldn't add methods that take NSValues.
One way out would be to add methods with different but similar names. For example, take a method like this:
- Code: Select all
- (void)doStuff:(int)aValue
Ideally, you'd want to do this:
- Code: Select all
[[mock expect] doStuff:[OCMArg any]]
That doesn't work, though. Assuming we changed OCMock so that it recognises a special prefix in method names, say "ocm_", and understands invocations of that method with an NSValue to refer to the method without the prefix and the primitive argument, then we could write the test like this:
- Code: Select all
[[mock expect] ocm_doStuff:[OCMArg any]]
However, this will result in a compiler warning because that method hasn't been declared anywhere. So, we'd also have to add this declaration somewhere in our test code:
- Code: Select all
@interface NSObject(DoStuffValueMethod)
- (void)ocm_doStuff:(NSValue *)aValue
@end
This would work but I think it too ugly and convoluted to add to OCMock. Opinions?