'Mockito issue w.r.t spring boot upgrade

We are facing an issue with Mockito post spring boot version upgrade

Following is the configuration

  • Mockito-all : 1.10.19
  • PowerMockito : 1.6.2
  • SpringBootVersion : 2.6.3
  • Junit : 4.12
  • Hamcrest-all : 1.3

Reported exception:

org.mockito.exceptions.misusing.UnfinishedStubbingException: 
Unfinished stubbing detected here:
-> at com.example.Sample(sample.java:109)

E.g. thenReturn() may be missing.
Examples of correct stubbing:
    when(mock.isOk()).thenReturn(true);
    when(mock.isOk()).thenThrow(exception);
    doThrow(exception).when(mock).someVoidMethod();

I tried changing versions of mockito from 1.1 to 1.10.19 and even with powermockito as well but it doesnt help. error keeps coming.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source