Closed GoogleCodeExporter closed 8 years ago
Are you saying that this works ok, without throwing any errors:
when(myClass.finalMethod()).thenReturn(someResult);
?
Original comment by szcze...@gmail.com
on 15 Jun 2010 at 3:23
It doesn't throw an error but it also doesn't work ok. In this case, the final
method stub returns null and the mock for the iface returns the result stubbed
for the final method.
Original comment by andy.kri...@gmail.com
on 15 Jun 2010 at 4:36
Can you submit a test case that shows this problem?
I cannot reproduce it.
//this fails gracefully for me all the time:
when(myClass.finalMethod()).thenReturn(someResult);
Original comment by szcze...@gmail.com
on 21 Jun 2010 at 8:28
Ok, I think I know what the problem is. Here's the limitation of the API:
myClass.nonFinalMethod();
when(myClass.finalMethod()).thenReturn(someResult);
Since mockito does not even know that you called a final method, mockito will
think that you are actually stubbing nonFinalMethod(). This cannot be fixed
because this is how java works (related to the evaluation order of arguments)
Original comment by szcze...@gmail.com
on 10 Jul 2010 at 1:13
Original comment by szcze...@gmail.com
on 13 Aug 2010 at 8:50
Original issue reported on code.google.com by
andy.kri...@gmail.com
on 14 Jun 2010 at 9:13