Вопрос

I would like to test my repositories that use MagicalRecord framework.

I'm doing the following (from this article : http://www.cimgf.com/2012/05/15/unit-testing-with-core-data/ ) :

@interface OMSTests : GHTestCase
@end

@implementation OMSTests

- (void)setUp;
{
[MagicalRecord setDefaultModelFromClass:[self class]];
[MagicalRecord setupCoreDataStackWithInMemoryStore];

}

- (void)tearDown;
{
[MagicalRecord cleanUp];
}

-(void)testXXX {
    NSManagedObjectContext * context = [NSManagedObjectContext defaultContext];

    [context save]; // context is not set 0x000000000000 

    OMSPointsEventEntity * entity = [OMSPointsEventEntity createEntity];

}
@end

I have the following error message when creating the entity :

Name: NSInternalInconsistencyException
File: Unknown
Line: Unknown
Reason: [RKManagedObjectStore defaultObjectStore] cannot be nil

Anyone can help me to find why I don't have a context instanciated ? I did not find useful documentation for this issue...

Это было полезно?

Решение 2

Oups I realized that #define MR_SHORTHAND (allow me to call [context save] instead of [context MR_save])was not working, so it was my problem....

Другие советы

Looks like you're trying to use RestKit and MagicalRecord together. You may want to set up RestKit's managed object context separately and/or base it off the default context provided by MagicalRecord.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top