Is it possible to do strict mocks with Mockito?

后端 未结 6 1379
傲寒
傲寒 2021-02-12 20:13

I\'d like to use strict mocks, at least when developing for the first time some tests against old code, so any methods invoked on my mock will throw an exception if I didn\'t sp

6条回答
  •  清歌不尽
    2021-02-12 20:48

    According to the source code of org.mockito.Mockito.RETURNS_DEFAULTS it selects its "what to do if no expectation" from a global setting. Furthermore "If there is no global configuration then it uses {@link ReturnsEmptyValues} (returns zeros, empty collections, nulls, etc.)" I have not yet been able to make that configuration.

提交回复
热议问题