5

I have some tests, where I use Mockito mocks. I do not use verifications in the test at all. Now I would like to make some performance tests, and the mocks cause OutOfMemoryError. I could try to refactor the code to be able to "reset" the mocks. However it would be a lot easier, if Mockito could create mocks, which do not record their invocations. Is it somehow possible?

Maciej Kowalski
  • 25,605
  • 12
  • 54
  • 63
Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113

1 Answers1

7

Yes. You want a "stub only" mock.

Xxxx mockXxxx = mock(Xxxx.class, withSettings().stubOnly());

This will make a mock of class Xxxx that will let you do stubbing, but not record any invocations.

Dawood ibn Kareem
  • 77,785
  • 15
  • 98
  • 110