Hi, I wanted to use `mockito-inline` to mock some final methods from other libraries (Not ideal, I know). Once I replaced `mockito-core` with `mockito-inline` 100s of unit tests started failing. Saw 3 unique issues mentioned below:
1. Cannot mock this class
Code where things fail: Mockito.spy(dbi.open(DaoClassname.class));
and dbi has a connection to a db running in embedded maria db process
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$431b21c8.
If you're not sure why you're getting this error, please report to the mailing list.
Java : 1.8
JVM vendor name : Oracle Corporation
JVM vendor version : 25.241-b07
JVM name : Java HotSpot(TM) 64-Bit Server VM
JVM version : 1.8.0_241-b07
JVM info : mixed mode
OS name : Mac OS X
OS version : 10.15.7
2. Issues regarding static mocking (I did find a workaround to this and it seems like a bug)
BDDMockito.given(static method call).willReturn(an object);
started failing with below error
org.mockito.exceptions.misusing.NotAMockException: Argument should be a mock, but is: class java.lang.Class
3. Issues verifying static method mocking
org.mockito.exceptions.misusing.NotAMockException:
Argument passed to verify() is of type Class and is not a mock!
Make sure you place the parenthesis correctly!
See the examples of correct verifications:
verify(mock).someMethod();
verify(mock, times(10)).someMethod();
verify(mock, atLeastOnce()).someMethod();
I have found a workaround for #2 and looking for more input on #1 and #3 . Any help is appreciated.
Thanks