BabyMock2: Stubbing individual methods from existing instance?

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

BabyMock2: Stubbing individual methods from existing instance?

Damien Pollet
Hi, I'm porting unit tests to BabyMock2 from another mocking framework
(DoubleAgents from VW).

Some tests wrap an existing domain object in order to exercise some of
its code, while controlling the return value of one of its methods
(one method is stubbed). I'm guessing this is technically possible in
BabyMock2, since it uses the same approach as Ghost proxies, but the
readme does not show how… is it currently possible ?

(if it's not there, consider this an official feature request :)

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Reply | Threaded
Open this post in threaded view
|

Re: BabyMock2: Stubbing individual methods from existing instance?

Attila Magyar
This is not supported. BabyMock is designed to test the message flow between objects, and not the internal implementation of an object. If the part what you want to stub out is not a private implementation detail then maybe extracting it to an object could help, otherwise couldn't you test the whole object?
Reply | Threaded
Open this post in threaded view
|

Re: BabyMock2: Stubbing individual methods from existing instance?

Damien Pollet-2
Well, I'm porting existing code with tests, so I would prefer to avoid
changing how they work.
Now I might as well consider it a rewrite…

On 28 October 2014 21:49, Attila Magyar <[hidden email]> wrote:

> This is not supported. BabyMock is designed to test the message flow between
> objects, and not the internal implementation of an object. If the part what
> you want to stub out is not a private implementation detail then maybe
> extracting it to an object could help, otherwise couldn't you test the whole
> object?
>
>
>
> --
> View this message in context: http://forum.world.st/BabyMock2-Stubbing-individual-methods-from-existing-instance-tp4787228p4787303.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: BabyMock2: Stubbing individual methods from existing instance?

Sean P. DeNigris
Administrator
In reply to this post by Damien Pollet
Damien Pollet wrote
(if it's not there, consider this an official feature request :)
We tried before (http://forum.world.st/Unifying-Testing-Ideas-tp4726787p4727283.html) but he wouldn't drink the partial stub koolaid ;)
Cheers,
Sean