appDelegate 实例显示 nil 值,测试用例“testAppDelegate”失败。苹果开发者网站提供的示例代码也是如此,但正在使用 SenTestCase,请帮帮我,即使目标是根据 WWDC 2013 视频“Testing in Xcode 5 session 409”设置的
@interface Tests : XCTestCase
{
AppDelegate *appDelegate;
AppViewController *appVC;
UIView *appView;
}
@end
@implementation Tests
- (void)setUp
{
[super setUp];
appDelegate = [[UIApplication sharedApplication] delegate];
appVC = appDelegate.appViewController;
appView = appVC.view;
}
- (void)tearDown
{
[super tearDown];
}
- (void)testAppDelegate
{
XCTAssert(appDelegate, @"Cannot find the application delegate");
}
- (void)testCheckForViewInitializatio
{
XCTAssert(appVC, @"AppViewController initialized");
}