Export to GitHub

mockito - issue #145

Introduce 'delegating' answer to allow spying on proxied objects


Posted on Nov 12, 2009 by Massive Monkey

For example:

IMethods mock = mock(IMethods.class, new Answer() { public Object answer(InvocationOnMock invocation) throws Throwable { return invocation.getMethod().invoke(delegate, invocation.getArguments()); } });

This allows spying some 'weird' objects, like proxied objects. Can be helpful for legacy code (see lengthy discussion at the end of issue 29).

Comment #1

Posted on Feb 14, 2010 by Massive Monkey

(No comment was entered for this change.)

Comment #2

Posted on Nov 7, 2010 by Massive Monkey

(No comment was entered for this change.)

Comment #3

Posted on Mar 5, 2012 by Happy Horse

Also see issue 275 and issue 280

Comment #4

Posted on Mar 7, 2012 by Happy Horse

Issue 280 has been merged into this issue.

Comment #5

Posted on Mar 9, 2012 by Happy Horse

Fixed in revision 6daa4d19a08c Thx to José Paumard for contributing the code.

Comment #6

Posted on Mar 9, 2012 by Happy Horse

Issue 275 has been merged into this issue.

Comment #7

Posted on May 13, 2012 by Massive Monkey

(No comment was entered for this change.)

Comment #8

Posted on Jun 3, 2012 by Massive Monkey

(No comment was entered for this change.)

Status: Fixed

Labels:
Type-Enhancement Priority-Medium Milestone-Release1.9.5-rc1