Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

CoreData test utilities? #6

Closed
jeremy-w opened this issue May 11, 2015 · 2 comments
Closed

CoreData test utilities? #6

jeremy-w opened this issue May 11, 2015 · 2 comments

Comments

@jeremy-w
Copy link
Member

Are there any blobs of code we frequently rewrite as part of testing something that relies on Core Data? If so, could we make those available for use in tests alongside the useful methods available for getting Core Data set up in the main app?

@lyricsboy
Copy link
Contributor

The most reusable thing I frequently appreciate is the ability to create stack backed by an in-memory persistent store. So, for example, in an app I have an initializer like:

typedef NS_ENUM(NSUInteger, PSICoreDataStackStoreType) {
    PSICoreDataStackStoreTypeInMemory,
    PSICoreDataStackStoreTypeOnDisk,
};

...

- (instancetype)initWithStoreType:(PSICoreDataStackStoreType)storeType;

And then when I'm adding the persistent store, I switch on storeType as appropriate.

Having the stack use a scratch store makes it really easy to run tests in isolation.

@rcedwards
Copy link
Contributor

I'd really like to add some examples of unit testing a model version migration also.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants