0

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

Son Nguyen
  • 13
  • 4
  • Can this reproduced with the current Eclipse instead of the retro Eclipse you have which is more than 2 years and 6 releases behind (if yes, please provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)). – howlger Aug 07 '21 at 14:51
  • I will try to reproduce this issue on the latest Eclipse and let you know. But Eclipse 2018-12 that is our project request so I still need help to revolve this issue using eclipse 2018-12 – Son Nguyen Aug 07 '21 at 15:08
  • Really, your project request is to use outdated software? There is a separate Stack Exchange for [retrocomputing](https://retrocomputing.stackexchange.com). – howlger Aug 07 '21 at 17:04
  • Actually, I tried to use the latest Eclipse already but it has some errors in Markers and I don't know why and how to resolve it. They are: The container 'Maven Dependencies' references non existing library '/home/son/.m2/repository/jdk/tools/jdk.tools/1.6/jdk.tools-1.6.jar' and /com/sun/activation/javax.activation/1.2.0/javax.activation-1.2.0.jar'. I sure that I not use these libraries in my project. I have just tried again with Eclipse 2021-06, the same this issues and TestNG can not start to run/debug – Son Nguyen Aug 08 '21 at 04:31
  • TestNG can work/debug with Eclipse 2021-06 now (Markers still has errors with Java Build Path as upper comment) and yes, for the current Eclipse, this issue still happen. For the minimal reproducible example, it takes time to create but I will try (I cannot share my current project code) – Son Nguyen Aug 08 '21 at 10:13

0 Answers0