How to Mock Static method of Util class in Service Implementation
Hi Team,
I have a git repository(Repo A) which has dependent on other main repository (Repo B). In Repo A we have a service implementation. In Repo B we have common code, here we have a util class and it has a static methods. We are calling these static methods from Repo B in Repo A. Now we are writing the Junit implementation for service class in Repo A. I am trying to mock this static method as mentioned below. Mockito.mockStatic(Utils.class); Mockito.when(Utils.getString()).thenReturn("Mocked string"); . i have added dependencies in my Repo A core POM and parent POM files.
I am facing issue i am not able to use the static method. I am seeing error "Cannot resolve method 'mockStatic' in 'Mockito'". Can someone help me on this issue. Your help is much appreciated.
https://sourcedcode.com/blog/aem/junit/junit5/mocking-static-methods-in-junit5
Thanks,
Praveena.
