eclipse-jdt / eclipse-jdt/eclipse.jdt.debug

Unable to debug when using mockito-inline

Open
#234 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
23
Forks
68
Avg merge
1d 4h
Merged PRs (30d)
13

Description

Original issue by @imro2 : https://github.com/mockito/mockito/issues/2743

I am unable to debug tests when using mockito-inline or mock-maker-inline. The issue was previously reported in https://github.com/mockito/mockito/issues/2082 and marked closed, but I am still experiencing the problem.

I am using:
Windows 10
Eclipse 2020-06
Eclipse Adomptium JDK 11 Hotspot
mockito-inline 3.12.4 also tested with 4.7.0

Sample gradle project to recreate:

```
package MockitoTest;

public class Library {
public boolean someLibraryMethod() {
return true;
}

public void someOhterLibraryMethod() throws Exception {
int[] arr = new int[5];
for(int i = 0; i < 5 ; i++) {
arr[i] = i;
if(i==3) {
throw new Exception("Break it!");
}
}
}
}
```
```
package MockitoTest;

import org.junit.Test;
import org.mockito.Mockito;
import static org.junit.Assert.*;

public class LibraryTest {
@Test public void testSomeOtherLibraryMethod() throws Exception{
Library classUnderTest = Mockito.spy(new Library());
Mockito.doReturn(false).when(classUnderTest).someLibraryMethod();
try {
classUnderTest.someOhterLibraryMethod();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
assertFalse("someLibraryMethod should return 'false'", classUnderTest.someLibraryMethod());
}
}
```
```
plugins {
id 'java-library'
}
repositories {
jcenter()
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:28.2-jre'
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-inline:3.12.4"
}
```
I can place breakpoint anywhere in the tested class and it is being ignored. When I step in from the test class, the IDE shows com.sun.jdi.InternalException: Got error code in reply:35 occurred retrieving 'this' from stack frame. I can then do some stepping, but it does not move in the way expected and even loses position. I am not able to inspect any variables.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.