如何在OCUnit上模拟UIApplication,委托,逻辑测试窗口?

时间:2012-07-06 09:33:51

标签: ios mocking uiapplication

看下面的代码,我需要在逻辑测试中做模拟,难的是[UIApplication sharedApplication]总是返回nil,你如何聪明地解决这个问题?谢谢。

    UIWindow* root = [UIApplication sharedApplication].delegate.window;
    UIWebView *aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    [aWebView setDelegate:tracker];
    [aWebView loadRequest:request];
    [root addSubview:aWebView];
    [aWebView release], aWebView = nil;

0 个答案:

没有答案