gpt4 book ai didi

ios - Xcode 7 Magical Record 单元测试失败

转载 作者:技术小花猫 更新时间:2023-10-29 10:28:06 26 4
gpt4 key购买 nike

从 Xcode 6.4 升级到 Xcode 7(现在是 7.0.1)后,我的项目在开始单元测试时崩溃了。我的 iOS 项目正在使用 Magical Record 并且应用程序在此断言时崩溃:

    + (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'

关于ios - Xcode 7 Magical Record 单元测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32952060/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com