Mocking Core Data
Posted: 23 Dec 2013, 18:26
I *think* I have created an extremely simple way to mock managed objects with OCMock. Is there anyway this would be useful in the main repo? Basically what I'm doing is subclassing OCClassMockObject and overriding:
There are probably a lot of things wrong with this that I haven't thought about, but it seems like it works (I've only done some very simple testing).
- Code: Select all
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
NSString *sel = NSStringFromSelector(aSelector);
if ([sel rangeOfString:@"set"].location == 0) {
return [NSMethodSignature signatureWithObjCTypes:"v@:@"];
} else {
return [NSMethodSignature signatureWithObjCTypes:"@@:"];
}
}
There are probably a lot of things wrong with this that I haven't thought about, but it seems like it works (I've only done some very simple testing).