0

I have following code line:

when(htmlEmailSpy.setFrom(anyString())).thenReturn(null);

Following code executes real htmlEmailSpy.setFrom(...) but it throws exception.

@Spy
HtmlEmail htmlEmailSpy = new HtmlEmail();

What do I wrong?

my aim - set new behaviour to spy object.

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

1 Answers1

2

I have resolved problem:

doReturn(null).when(htmlEmailSpy).setFrom(anyString());

took from: Mockito: Trying to spy on method is calling the original method

Community
  • 1
  • 1
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710