I write a test case to test for my service (has Method Under Test - MUT) using TestNG, Mockito-inline (to mock static). My issue is: when I set breakpoints at MUT then Eclipse's cursor cannot stop at these breakpoints. If set breakpoints at test code, the cursor stop and highlight correctly.
I tried to back to Mockito-core (but cannot use Mockito-static anymore, same version 3.11.2) then every breakpoints (in test code and in my service) work correctly.
Here is detail:
A test case: Breakpoints at this test file work correctly
try (MockedStatic<myClass> mockMyClass = Mockito.mockStatic(myClass.class)) {
mockMyClass.when(() -> myClass.get(anyInt()).thenReturn(myReturnObject);
myService.myMethodUnderTest();
}
My service code: another file (myService) has many methods (these methods - myMethodUnderTest call the static method myClass.get(int value))
public void myMethodUnderTest(int value) {
line 1; // if set breakpoint here, Eclipse's cursor does not stop, everything works
normally as without this breakpoint. This code line must be run without any
conditions
myClass.get(value); // the static mock works correctly
line n; // If set breakpoint -> the same line 1
}
Here is my detail environment: Ubuntu 20.04, Eclipse 2018-12, Java 1.8, Spring 5.1.9, TestNG 7.4.0, Mockito 3.11.2 (core and inline)
I tried to use Mockito-inline 3.8.0 but the same issue.
When I debug step by step (F5, F6) the Eclipse'cursor is not correct (still highlight a line but wrong logic) when running in the method under test too (still correct when running in the test code).
Anyone can help to resolve this issue, run debug step by step correctly with Mockito-inline.
Thank you very much