我的單元測試目標崩潰我對我的項目進行單元測試與指定的應用程序委託類,從我的正常應用程序委託不同。 UnitTestAppDelegate
不是應用目標的成員,只是測試目標的成員。單元測試上的XCode 7
在Xcode 6中它正在工作,使用了正確的委託,但是在Xcode 7(beta 6)中,應用程序在嘗試加載到測試委託時崩潰。我測試使用模擬器,不論是iOS 8和9
該文件是不知道的應用目標:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to instantiate the UIApplication delegate instance. No class named UnitTestAppDelegate is loaded.'
我main.m
文件看起來像這樣:
int main(int argc, char* argv[])
{
int returnValue;
@autoreleasepool
{
if (NSClassFromString(@"XCTest") != nil)
{
//use the test delegate
returnValue = UIApplicationMain(argc, argv, nil, @"UnitTestAppDelegate");
}
else
{
//use the normal delegate
returnValue = UIApplicationMain(argc, argv, nil, @"AppDelegate");
}
}
return returnValue;
}
我也附上如何配置我的方案的屏幕截圖(運行和測試在同一個方案中,儘管我也嘗試將它們分開)。
添加我的UnitTestAppDelegate
爲應用目標的構件將崩潰,但我顯然不希望將文件添加到我的應用程序。
其他人遇到過這個?
任何想法?
我創建了一個小型示範項目,如果有人想嘗試弄明白。 https://github.com/ashavit/UnitTests-Different-AppDelegate – AShavit