Can I use OCMock to create light-weight CoreData objects?

Discussion of the OCMock framework. If you have patches we would prefer you to send them to the mailing list, but attaching them to a topic is possible, too.

Can I use OCMock to create light-weight CoreData objects?

Postby gregh » 27 Apr 2011, 22:53

Is it possible to use OCMock to create light weight test object copies of the auto-generated CoreData managed objects from XCode 4 in my iphone app? That is such that you don't have to touch the autogenerated classes. So ideally it would be something like: "create a mock object of class XXXX", where XXX was a coredata managed class. Then it would need to somehow see that the coredata managed object classes has X dynamic properties, and then it would need to replicate these in the mock object as non-dynamic.

If yes, is there any example code for this?

Background - I'm finding that where I pass a config object I retrieve from core data (for my iPhone app) and I pass this around to various methods, that when I go to test these methods it is there difficult because I have to create a core data object. If I create it directly (without using core data infrastructure) it doesn't work as the properties are dynamic. An example of an autogenerated coredata managed object is:

Code: Select all
@interface WEView : NSManagedObject {
  @private
}
  @property (nonatomic, retain) NSString * title;
@end


#import "WEView.h"
@implementation WEView
   @dynamic title;
@end
gregh
 
Posts: 1
Joined: 27 Apr 2011, 22:43

Return to OCMock