Mocking ZnClient

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Mocking ZnClient

Damien Cassou-2
Hi,

I need to write unit tests for code that fetches data on the web through
ZnClient. Is there a way to temporarily replace all creations of
ZnClient instances by instances of another class that will reply with
fixed results without fetching on the web?

I already wrote something like that for the Pharo launcher. I'm now
looking for something that already exists outside so I don't have to
extract this into a new library by myself.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Mocking ZnClient

Sven Van Caekenberghe-2
Damien,

As far as I know this does not (yet) exist.

I know that Norbert did some work mocking actual connections, so that a client can directly connect to a server's handler without doing any networking, if I remember correctly, but I don't think that is what you are looking for.

Sven

> On 14 Sep 2015, at 15:31, Damien Cassou <[hidden email]> wrote:
>
> Hi,
>
> I need to write unit tests for code that fetches data on the web through
> ZnClient. Is there a way to temporarily replace all creations of
> ZnClient instances by instances of another class that will reply with
> fixed results without fetching on the web?
>
> I already wrote something like that for the Pharo launcher. I'm now
> looking for something that already exists outside so I don't have to
> extract this into a new library by myself.
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>


Reply | Threaded
Open this post in threaded view
|

Re: Mocking ZnClient

demarey
In reply to this post by Damien Cassou-2
It is very easy to do by using BabyMock2 for example

Le 14 sept. 2015 à 15:31, Damien Cassou a écrit :

> Hi,
>
> I need to write unit tests for code that fetches data on the web through
> ZnClient. Is there a way to temporarily replace all creations of
> ZnClient instances by instances of another class that will reply with
> fixed results without fetching on the web?
>
> I already wrote something like that for the Pharo launcher. I'm now
> looking for something that already exists outside so I don't have to
> extract this into a new library by myself.
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>


smime.p7s (5K) Download Attachment