3 ms·
I think one of the biggest issues is the definitions we use. Some developers would define mock in the wide sense, as any kind of double to replace a dependency
by elboru 4y ago
I think one of the biggest issues is the definitions we use.
Some developers would define mock in the wide sense, as any kind of double to replace a dependency. Other developers have a narrower definition, as doubles that verify interactions with the dependency (interaction testing https://testing.googleblog.com/2013/03/testing-on-toilet-testing-state-vs.html https://testing.googleblog.com/2013/03/testing-on-toilet-tes...).
In this case, the author mentions mocks and spies, therefore he's referring to "interaction testing". In other words, tests that verify that the dependency was called in the "right" way. If you own those dependencies, and later you refactor them you'll also need to refactor any test that used "interaction testing". Refactoring becomes a tedious and sometimes difficult task.
If by mock, you simply mean code (written by you or by a "Mock" library) that replaces a dependency to get the right data inside the SUT for the test, but that it's not attached to the dependency implementation, then most of the issues are gone.