ios – Xcode 7魔法记录单元测试失败

Xcode 6.4升级Xcode 7(现在为7.0.1)后,我的项目在启动单元测试时会崩溃.我的iOS项目正在使用魔法记录,应用程序在这个断言中崩溃:
+ (NSManagedobjectContext *) MR_defaultContext
{
    @synchronized(self) {
        NSAssert(MagicalRecordDefaultContext != nil,@"Default context is nil! Did you forget to initialize the Core Data Stack?");
        return MagicalRecordDefaultContext;
    }
}

我已经评论过我以前的所有测试,并且这两个测试都显示出相同的行为:

#import <XCTest/XCTest.h>

@interface BadTests : XCTestCase

@end

@implementation BadTests

- (void)setUp {
    [super setUp];
}

- (void)tearDown {
    [super tearDown];
}

- (void)testSanity {
    XCTAssert(1 == 1);
}

@end

#import <XCTest/XCTest.h>
#import <MagicalRecord/MagicalRecord.h>

@interface BadTests : XCTestCase

@end

@implementation BadTests

- (void)setUp {
    [super setUp];
    NSLog(@"*** USING IN MEMORY STORE ***");
    [MagicalRecord setLoggingLevel:MagicalRecordLoggingLevelDebug];
    [MagicalRecord setupCoreDataStackWithInMemoryStore];
}

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

- (void)testSanity {
    XCTAssert(1 == 1);
}

@end

用相同的测试恢复到Xcode 6可以解决问题.

解决方法

结束通过调整我的Podfile解决问题:
link_with 'TestApp','TestAppTests','TestAppUITests'

platform :iOS,'8.1'

target 'TestApp' do
     pod 'MagicalRecord'
end

target 'TestApp' do
     pod 'OHHTTPStubs'
end

以前我的pod文件看起来像这样:

platform :iOS,'8.1'
pod 'MagicalRecord'
pod 'OHHTTPStubs'

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...