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

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is OFF
Smilies are ON
Topic review
   

Expand view Topic review: Can I use OCMock to create light-weight CoreData objects?

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

Post by 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

Top

cron