Annotation Type InjectSpy


  • @Target(FIELD)
    @Retention(RUNTIME)
    public @interface InjectSpy
    When used on a field of a test class, the field becomes a Mockito spy, that is then used to spy on the normal scoped bean which the field represents
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean delegate
      true will create a mock that delegates all calls to the real bean, instead of creating a regular Mockito spy.
    • Element Detail

      • delegate

        boolean delegate
        true will create a mock that delegates all calls to the real bean, instead of creating a regular Mockito spy.

        You should try this mode when you get errors like "Cannot call abstract real method on java object!" when calling a default interface method of a spied bean.

        See Also:
        AdditionalAnswers.delegatesTo(Object)
        Default:
        false