模拟when().thenReturn()返回值不起作用

Posted 泡^泡

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模拟when().thenReturn()返回值不起作用相关的知识,希望对你有一定的参考价值。

使用any()替换anyString()模拟参数的方法来修复它。
Mockito.when(eventRepository.findOneById(any())).thenReturn(Optional.of(sampleEventFromDb));

以上是关于模拟when().thenReturn()返回值不起作用的主要内容,如果未能解决你的问题,请参考以下文章