我想测试使用 MagicalRecord 框架的存储库。
我正在执行以下操作(来自这篇文章: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
创建实体时出现以下错误消息:
Name: NSInternalInconsistencyException
File: Unknown
Line: Unknown
Reason: [RKManagedObjectStore defaultObjectStore] cannot be nil
任何人都可以帮助我找到为什么我没有实例化的上下文?我没有找到有关此问题的有用文档...