I have an application, for which I use Objective Resource to create local objects to reflect remote responses.
The specific model classes have subclass an abstract-ish class to give them all a variety of additional functionality, most importantly the ability to serialize, write to disk, and load from disk, regardless regardless of what the specific properties are of that specific model object.
superclass.m
-(BOOL)saveToDisk{
...serializes and encodes all properties to disk
...return success
}
subclass.h : superclass
@property (nonatomic, retain) NSString* name;
@property (nonatomic, retain) NSArray* friends;
...etc
Then I would call
instanceOfSubclass.name = "joe"
NSLog(@"save status = %d",[instanceOfSubclass saveToDisk]);
I am new to BDD and test driven development generally. How do I create a mock object, using kiwi, to test this functionality abstractly, since I use this framework in lots of projects.
Specifically, I want to build tests that ensure that a subclass with various types of properties can be saved loaded, deleted, and overwritten.
My understanding is that this is where stubs and mocks come in, but I can't seem to figure out how to mock properties. Do I have to create an actual class with those properties?
There is some documentation for you at this location. Basically, Kiwi provides an Objective-C category on
NSObject
that you have access to when you#import "Kiwi.h"
. This allows all objects that inherit fromNSObject
to respond to+mock
,mockWithName:
, etc., which is configurable via theKWMock
class.Hope this helps, and sorry its a bit late :)