Mocking execte() method of HttpClient [duplicate]
问题 This question already has an answer here : Mocked HttpClient calls actual method (1 answer) Closed 5 months ago . I want to mock execute method of HttpClass to return a dummy response, but my test code is acutally executing the request. Class Code - class MyService { private CloseableHttpClient newHttpClient() { try { SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( new SSLContextBuilder().loadTrustMaterial(TrustAllStrategy.INSTANCE).build(), NoopHostnameVerifier.INSTANCE);