Annotation Interface 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
    If true, then Quarkus will change the scope of the target Singleton bean to ApplicationScoped.
    boolean
    true will create a mock that delegates all calls to the real bean, instead of creating a regular Mockito spy.
  • Element Details

    • 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
    • convertScopes

      boolean convertScopes
      If true, then Quarkus will change the scope of the target Singleton bean to ApplicationScoped. This is an advanced setting and should only be used if you don't rely on the differences between Singleton and ApplicationScoped beans (for example it is invalid to read fields of ApplicationScoped beans as a proxy stands in place of the actual implementation)
      Default:
      false