From 0dea36990a2e2034ee6bbe8991ad40f5760bd0ca Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:28:13 +0100 Subject: [PATCH] fixed files form Mockito #32 --- .../mockito/internal/configuration/SpyAnnotationEngine.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/Mockito/32/org/mockito/internal/configuration/SpyAnnotationEngine.java b/projects/Mockito/32/org/mockito/internal/configuration/SpyAnnotationEngine.java index e292e13..dc2ef6a 100644 --- a/projects/Mockito/32/org/mockito/internal/configuration/SpyAnnotationEngine.java +++ b/projects/Mockito/32/org/mockito/internal/configuration/SpyAnnotationEngine.java @@ -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 { @@ -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);