Search code examples
iphoneunit-testingxcode4uiwebviewocunit

Unit testing with UIWebView


When creating an UIWebView inside an unit test I get EXC_BAD_ACCESS:

-(void)test1 {
    [[UIWebView alloc] initWithFrame:CGRectZero];  // EXC_BAD_ACCESS
}

Is there a special configuration to run units test that involve UIWebView?

I'm using OCUnit/SenTest on XCode 4.2.


Solution

  • Apparently this only happens when unit testing a static library directly. Most likely whatever UIWebView needs is not loaded with an empty test host.

    When unit testing an app this doest not occur.