Testing Android ContentProvider that accesses the Internet -


I have written my own Android code ContentProvider to access some internet resources. I am trying to write some unit tests, but I do not want those tests to actually reach the Internet.

Behind the curtain, using the DefaultHttpClient class to access my code is Scarf. In fact, I would like to know how I can use the ProviderTestCase2 class to block any HTTP requests and return a predefined string "response" instead.

I'm assuming that to do something like this, I can either mock in the ContentResolver or context , but I need some guidance. .


Comments