T.apex

  • Docs
  • Tutorials
Docs Menu
  • BDD Style
  • Mocking
    • Mock Creation
    • Mock Behavior
    • Argument Predicates
    • Mock Verification
  • Test Data

Mock Verification Guide

Mock Verification

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.

MethodDescription
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

Contribute on Github! Edit this section.