PowerMockito.doReturn returns null
This is my class under test: public class A { public Integer callMethod(){ return someMethod(); } private Integer someMethod(){ //Some Code HttpPost httpPost = new HttpPost(oAuthMessage.URL); //Some Code HttpClient httpClient = new DefaultHttpClient(); HttpResponse httpResponse = httpClient.execute(httpPost); ------1 Integer code = httpResponse.getStatusLine().getStatusCode(); ---2 return code; } Now I want to mock the line 1 & 2 & return a mock HttpResponse & code. I have tried this but failed: @RunWith(PowerMockRunner.class) @PowerMockIgnore("javax.crypto.*") public class TestA { //Spying