Skip to content

Commit

Permalink
fixed files form Mockito #32
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 446495c commit 0dea369
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.mockito.exceptions.base.MockitoException;
import org.mockito.internal.util.MockUtil;

import static org.mockito.Mockito.withSettings;

@SuppressWarnings({"unchecked"})
public class SpyAnnotationEngine implements AnnotationEngine {
Expand Down Expand Up @@ -46,7 +47,10 @@ public void process(Class<?> context, Object testClass) {
// instance has been spied earlier
Mockito.reset(instance);
} else {
field.set(testClass, Mockito.spy(instance));
field.set(testClass, Mockito.mock(instance.getClass(), withSettings()
.spiedInstance(instance)
.defaultAnswer(Mockito.CALLS_REAL_METHODS)
.name(field.getName())));
}
} catch (IllegalAccessException e) {
throw new MockitoException("Problems initiating spied field " + field.getName(), e);
Expand Down

0 comments on commit 0dea369

Please sign in to comment.