What steps will reproduce the problem?
Write a test, where a field is annotated with @Mock(answer =
Answers.CALLS_REAL_METHODS)
What is the expected output? What do you see instead?
In Mockito, this works perfectly. It simply calls the real methods of the mock.
In PowerMock, this does nothing. It's simply a mock. You have to mock the
methods to get any result.
What version of the product are you using? On what operating system?
PowerMockito 1.5.4
Mockito 1.9.5
Mac OS X 10.9.2
Please provide any additional information below.
Workaround for this problem: let's say that I have this mock present in my
test:
@Mock(answer = Answers.CALLS_REAL_METHODS) private TimestampToStringConverter
timestampToStringConverter;
In order to have it actually call the real methods of the mock, I have to do
this in my setup method:
when(timestampToStringConverter.convert(any(Timestamp.class))).thenCallRealMetho
d();
It is infuriating, however, because you have to actually do this for EVERY
method you want to use in your test. If you have a class which has 8 methods,
which you all use, you're doing this for every single one of them. It leads to
an ugly blob of code.
Original issue reported on code.google.com by ger...@gmail.com on 6 Mar 2014 at 8:21
Original issue reported on code.google.com by
ger...@gmail.com
on 6 Mar 2014 at 8:21