Interface AnnotationEngine

All Known Implementing Classes:
DefaultAnnotationEngine, InjectingAnnotationEngine, SpyAnnotationEngine

public interface AnnotationEngine
Configures mock creation logic behind @Mock, @Captor and @Spy annotations

If you are interested then see implementations or source code of MockitoAnnotations.initMocks(Object)

  • Method Summary

    Modifier and Type
    Method
    Description
    createMockFor(Annotation annotation, Field field)
    Deprecated.
    Please use process(Class, Object) method instead that is more robust
    void
    process(Class<?> clazz, Object testInstance)
    Allows extending the interface to perform action on specific fields on the test class.
  • Method Details

    • createMockFor

      @Deprecated Object createMockFor(Annotation annotation, Field field)
      Deprecated.
      Please use process(Class, Object) method instead that is more robust

      Creates mock, ArgumentCaptor or wraps field instance in spy object. Only if of correct annotation type.

      Parameters:
      annotation - Annotation
      field - Field details
    • process

      void process(Class<?> clazz, Object testInstance)
      Allows extending the interface to perform action on specific fields on the test class.

      See the implementation of this method to figure out what is it for.

      Parameters:
      clazz - Class where to extract field information, check implementation for details
      testInstance - Test instance