tags:

views:

46

answers:

1

Hi, suppose I want to mock a method with the following signature:

public A foo(A a)

I want foo to be mocked in a way that it returned what it received (that is the same instance a)

I tried unsuccessfully the following:

Capture<A> capture = new Capture();
expect(myclass.foo(capture)).andReturn(capture.getValue());

This does not work because the capture is still empty when getValue() is called.

Any ideas?

Thanks

+2  A: 
01
Looks a bit too complex. Is there not an easier way?
odwl
you could extract answer to your own class.
01