Search code examples
javajunitquarkus

@InjectMock(deepMock=true) deprecation fix, How to use it after removal?


I got a project that I am doing a Quarkus Update on. The project uses the DeepMock Option while doing JUnit Tests. Probleme is that this is marked for removal and making issues when trying to remove.

So far I haven't found any docs detailing how to replace DeepMock with oncoming JUnit and Mokito versions. Does anyone have an Solution?

I tried to just remove to option, leading to a failure of all effected JUnit-Tests


Solution

  • The previous @InjectMock annotation (io.quarkus.test.junit.mockito.InjectMock) is deprecated for removal, because it may be used on places where its configuration options (convertScopes, returnsDeepMocks) don't make sense. The new @InjectMock annotation (io.quarkus.test.InjectMock) doesn't have the configuration options.

    The replacement is the @MockitoConfig annotation (io.quarkus.test.junit.mockito.MockitoConfig), which has the same configuration options. Use the new @InjectMock annotation together with @MockitoConfig.