vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

Mocked objects are shown as null

Open fssrepository opened this issue 1 year ago • 0 comments

Vscode 1.79.2 Ubuntu 20.4


@Service
public class Converters {
  private final List<String> something.

  public Converters() {
     this(new ArrayList<>();
  }

  public Optional<String> do(String v) {
  }

}

@ExtendsWith(MockitoExtention.class)
publi class VsCodeDebuggerTest
{
     @Mock
     public Converters something;

     public void shouldDoSomething() {
          when(something.do(any())).thenReturn()

          something.do("try");

          System.out.println(something); 

}
}

//with Mock.mock(something); same result,
//but with Mock.mock(something, withSettings.useConstructor(new Object[0]));
//returns non-null,
//however the mocked object in both case is functional.

I have spent quite a few time to debug the source code of the Mockito, as the null was very confusing, even if it was inside a proxy object.

Not sure, what i can expect, but while Mocking repositories, i have seen non-null objects.

fssrepository avatar Jul 08 '23 02:07 fssrepository