1

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...

Nicolas Henin
  • 3,244
  • 2
  • 21
  • 42

2 Answers2

0

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.

casademora
  • 67,775
  • 17
  • 69
  • 78
0

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....

Nicolas Henin
  • 3,244
  • 2
  • 21
  • 42