Class SpyAnnotationEngine

java.lang.Object
org.mockito.internal.configuration.SpyAnnotationEngine
All Implemented Interfaces:
AnnotationEngine

public class SpyAnnotationEngine extends Object implements AnnotationEngine
Process fields annotated with @Spy.

Will try transform the field in a spy as with Mockito.spy().

If the field is not initialized, will try to initialize it, with a no-arg constructor.

If the field is also annotated with the compatible @InjectMocks then the field will be ignored, The injection engine will handle this specific case.

This engine will fail, if the field is also annotated with incompatible Mockito annotations.

  • Constructor Details

    • SpyAnnotationEngine

      public SpyAnnotationEngine()
  • Method Details

    • process

      public AutoCloseable process(Class<?> context, Object testInstance)
      Description copied from interface: AnnotationEngine
      Processes the test instance to configure annotated members.
      Specified by:
      process in interface AnnotationEngine
      Parameters:
      context - Class where to extract field information, check implementation for details
      testInstance - Test instance