Mock
2022-02-11
Please have in mind these are field notes organized in a common structure that I use for myself or for my students, university classes and industrial activities. They may be messy, with errors and in some cases, without proper references. If you find your work (or part of it) here without proper acknowledgement, please let me know so I can fix it as soon as possible.
In software engineering I call a mock/stub/fake to a function/object that mimic the behavior of the original function/object (a.k.a mocked function/object).
I know there are differences between mock/stub/fake but I don't use them everyday.
To detect where we should use a mock, we need to analyze the piece of code under study (the one to be tested) looking for "seams" (more about this on
Testing Effectively With Legacy Code, By Michael Feathers)
Significant Revisions
Feb 11, 2022: Original publication on dariomac.com