You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Miguel Paraz <mp...@gmail.com> on 2011/06/25 09:47:51 UTC

Feasibility of Mocking HttpClient

Hi,

Is it feasible to mock HttpClient, with a mocking framework or with
custom implementations of the classes?
I would like to unit test my code that uses HttpClient, without going
out to the network (even if it's just localhost).

Thanks,
Miguel

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Feasibility of Mocking HttpClient

Posted by sebb <se...@gmail.com>.
On 25 June 2011 17:34, KARR, DAVID (ATTSI) <dk...@att.com> wrote:
>> -----Original Message-----
>> From: Miguel Paraz [mailto:mparaz@gmail.com]
>> Sent: Saturday, June 25, 2011 12:48 AM
>> To: HttpClient User Discussion
>> Subject: Feasibility of Mocking HttpClient
>>
>> Hi,
>>
>> Is it feasible to mock HttpClient, with a mocking framework or with
>> custom implementations of the classes?
>> I would like to unit test my code that uses HttpClient, without going
>> out to the network (even if it's just localhost).
>
> Mocking frameworks can mock almost anything.  Just take a look at Mockito or similar frameworks and you'll see how it's done.  Your job might be easier if your use of HttpClient was encapsulated in an application-specific layer that only performs that function, as it will likely be easier to mock that layer instead of HttpClient.

Also have a look at the HC Unit tests - they use Mockito for some tests.

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


RE: Feasibility of Mocking HttpClient

Posted by "KARR, DAVID (ATTSI)" <dk...@att.com>.
> -----Original Message-----
> From: Miguel Paraz [mailto:mparaz@gmail.com]
> Sent: Saturday, June 25, 2011 12:48 AM
> To: HttpClient User Discussion
> Subject: Feasibility of Mocking HttpClient
> 
> Hi,
> 
> Is it feasible to mock HttpClient, with a mocking framework or with
> custom implementations of the classes?
> I would like to unit test my code that uses HttpClient, without going
> out to the network (even if it's just localhost).

Mocking frameworks can mock almost anything.  Just take a look at Mockito or similar frameworks and you'll see how it's done.  Your job might be easier if your use of HttpClient was encapsulated in an application-specific layer that only performs that function, as it will likely be easier to mock that layer instead of HttpClient.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org