Closed GoogleCodeExporter closed 9 years ago
Hi!
This has to do with the behavior of Mockito, not Powermockito.
I refer to a question I recalled from the Mockito FAQ Found here:
http://code.google.com/p/mockito/wiki/FAQ.
"
Can I thenReturn() an inlined mock() ?
Unfortunately you cannot do this:
when(m.foo()).thenReturn(mock(Foo.class));
// ^
The reason is that detecting unfinished stubbing wouldn't work if we allow
above construct. We consider is as a 'trade off' of framework validation (see
also previous FAQ entry). However you can slightly change the code to make it
working:
//extract local variable and start smiling:
Foo foo = mock(Foo.class);
when(m.foo()).thenReturn(foo);
"
I hope this answers your question.
Sincerely,
Henrik
Original comment by zherkezhi
on 15 May 2012 at 12:57
My previous post probably was not very clear, basically it would have been
sufficient to say that as far as I know, this error is from Mockito not
Powermockito.
Original comment by zherkezhi
on 15 May 2012 at 1:03
Thanks for helping out zherkezhi!
Original comment by johan.ha...@gmail.com
on 15 May 2012 at 1:08
Oh sorry, I did not realize that this is not a Mockito project. Did you just
close it or move it to the proper place?
Original comment by kamot...@gmail.com
on 16 May 2012 at 12:35
Nevermind, submitted to mockito myself:
http://code.google.com/p/mockito/issues/detail?id=344
Original comment by kamot...@gmail.com
on 27 May 2012 at 3:05
Original issue reported on code.google.com by
kamot...@gmail.com
on 23 Feb 2012 at 10:13