How to Verify Mock Behavior
After the mock has been used, we can verify mock methods have been used as we expected.
T.verify(mock, 'run').toHaveBeenCalled();
We have three ways to verify mock method behaviors.
Method | Description |
---|---|
toHaveBeenCalled() | To verify that the method has been called |
toHaveBeenCalledTimes(Integer) | To verify that the method has been called N times |
toHaveBeenCalledWith(List | To verify that the method has been called with the given arguments |