On 2013-09-14 01:20, Leonard Brünings wrote:
> The usecase I see for delegation is, if you have an integration test and
> you want to make sure that a call to an external system was made you can
> simply wrap the instance in a spy and verify the call. Assuming that the
> instance doing the call is complex to setup.
That's one of the main use cases when I use Springockito in my in
integration tests.
> But what about the following: You could use the instance as a prototype by
> copying all fields to the actual spy, since you are using objenesis no
> constructor is called and the instance is used to set the correct state.
> This way you don't need to delegate and you can still to partial mocking,
> but you can also setup the correct internal state. ?
I also wanted to implement an ability to spy existing instances in the
similar way and I found that thread.
@Peter, do you see implementation problems with that approach in Spock?
@Peter, what would be required to modify in detached mocks PR [1] to
make it closer to pull into the code base?
[1] -
https://github.com/spockframework/spock/pull/17
Marcin
> On Friday, September 13, 2013 2:04:09 AM UTC+2, Peter Niederwieser wrote:
>>
>> On Sep 12, 2013, at 2:23 PM, Damokles <
l.bru...@googlemail.com<javascript:>>
>> wrote:
>>
>>> Why would you need to give up partial mocking? The way I see it, is that
>> you have a normal mock that by default delegates all non mocked calls to
>> the spied instance. Mockito certainly supports this kind of spying.
>>
>> As soon as you delegate rather than subclass, partial mocking will no
>> longer be possible, because the spy won't be able to intercept a call from
>> `delegate.foo` to `delegate.bar`. Mockito started out with delegation, and
>> later added a second kind of spy for this and other reasons. If possible,
>> I'd like to avoid supporting two kinds of spies.
>>
>> Cheers,
>> Peter
>>
>>
>
--
http://blog.solidsoft.info/ - Working code is not enough