Annotation Interface InjectMock


@Retention(RUNTIME) @Target({FIELD,PARAMETER}) public @interface InjectMock
Instructs the test engine to inject a mock instance of a bean into the annotated field or parameter.

This annotation is supported:

  • for fields and method parameters in a io.quarkus.test.component.QuarkusComponentTest,
  • for fields in a io.quarkus.test.QuarkusTest if quarkus-junit5-mockito is present.
The lifecycle and configuration API of the injected mock depends on the type of test being used.

Some test types impose additional restrictions and limitations. For example, only beans that have a client proxy may be mocked in a io.quarkus.test.junit.QuarkusTest.