I can’t make an HTTP call from an iPhone unit test!


I know I’m not supposed to do this in a unit test but as a learning test how would one go about making an NSURLConnection in a GTMSenTestCase? According to all the docs I’ve read for an NSURLConnection to work correctly the calling thread’s run loop must be operating in default mode. Does that mean I’ll have to setup my own RunLoop to get things working correctly? I thought I read somewhere that GTMSenTestCases don’t execute on a runloop and that their runloop needs to be manually set. Help?

One thought on “I can’t make an HTTP call from an iPhone unit test!

  1. Does that mean I’ll have to setup my own RunLoop to get things working correctly?

    Yes, or, at least, “SenTests” don’t work inside a runloop, you have to set one up, or you can do the URL request synchronously by using sendSynchronousRequest.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s