Performing behavior verification using mocks

Mocks are different from stubs rather than just testing the return value of a function, we focus on testing expectations from the collaborator functions' perspective. What kind of activities does a collaborator function expect? Here are some examples for our use case:

  • From the check_background function's perspective, was it called only once for each open_account call?
  • From the create_account function's perspective, was it called when a background check was successful?
  • From the create_account function's perspective, was it not called when the background check failed?
  • From the notify_account function's perspective, was it called with an account number that is greater than 0?

The process to set ...

Get Hands-On Design Patterns and Best Practices with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.