Mockito - what does verify method do?

后端 未结 2 412
野性不改
野性不改 2021-02-01 15:15

Let\'s say i have the following psuedo like test code:

 //Let\'s import Mockito statically so that the code looks clearer
 import static org.mockito.Mockito.*;
         


        
2条回答
  •  醉话见心
    2021-02-01 15:37

    Mockito.verify(MockedObject).someMethodOnTheObject(someParametersToTheMethod); verifies that the methods you called on your mocked object are indeed called. If they weren't called, or called with the wrong parameters, or called the wrong number of times, they would fail your test.

提交回复
热议问题