[翻译]  Xcode 7 Magical Record Unit Tests Fail

[CHINESE]  Xcode 7魔法记录单元测试失败


After upgrading from Xcode 6.4 to Xcode 7 (and now 7.0.1) my project crashes when starting unit tests. My iOS project is using Magical Record and the app crashes at this assertion:

从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;
    }
}

I've commented out all of my previous tests, and both of these tests show the same behavior:

我已经注释掉了我之前的所有测试,这两个测试都显示了相同的行为:

#import <XCTest/XCTest.h>

@interface BadTests : XCTestCase

@end

@implementation BadTests

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

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

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

@end

and

#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

Reverting back to Xcode 6 with the same tests resolves the issue.

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

2 个解决方案

#1


1  

Ended up resolving the issue by adjusting my Podfile:

通过调整我的Podfile结束解决问题:

link_with 'TestApp', 'TestAppTests', 'TestAppUITests'

platform :iOS, '8.1'

target 'TestApp' do
     pod 'MagicalRecord'
end

target 'TestApp' do
     pod 'OHHTTPStubs'
end

Previously my pod file just looked like this:

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

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

#2


0  

This situation can stem from the presence of old runtime environment as mentioned in the release notes:

这种情况可能源于发行说明中提到的旧运行时环境的存在:

Xcode processes may quit unexpectedly if older iOS Simulator runtimes (Xcode 6.x) are present on disk

如果磁盘上存在较旧的iOS模拟器运行时(Xcode 6.x),Xcode进程可能会意外退出

To check whether this is the cause, you can delete all old runtime libraries from /Library/Developer/CoreSimulator/Profiles/Runtimes

要检查这是否是原因,您可以从/ Library / Developer / CoreSimulator / Profiles / Runtimes中删除所有旧的运行时库


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号