I'm just starting with Robolectric. It seems to be working fine to mock most Android classes but when my class under test tries to create a DefaultHttpClient() it gets the dreaded "Stub!" error.
The class under test fails at this line:
HttpClient httpclient = new DefaultHttpClient();
even though the article at http://robolectric.blogspot.com/2011/01/how-to-test-http-requests.html?showComment=1297722651278#c3540420071421225744 seems to suggest this should just work.
My test looks like this:
@Before
public void setUp() throws Exception
{
Robolectric.addPendingHttpResponse(200, "OK");
service = new CheckinService();
}
@Test
public void testIt() throws IOException
{
// Fails at HttpClient httpclient = new DefaultHttpClient()
service.doStuff(Robolectric.application,
REG_ID,
TEST_DOMAIN);
}
Any idea what I'm doing wrong?