DEV Community

Discussion on: When should I (not) use mocks in testing?

Collapse
 
kettanaito profile image
Artem Zakharchenko

Hi, Alexander! Thank you for spotting the typo!

That section referred to the implementation detail testing: assertion of how the software works instead of what it does. The getUser method can be implemented differently. For example, in the future, you may decide that you can resolve the user from elsewhere than sessions (abstract examples). If your test checks that lookupSessions must be called, the test would fail, while the functionality remains.

The goal of any test is to verify the intention behind the implementation, but not the implementation itself. Relying on the latter is often what makes tests brittle, and, most importantly, useless when refactoring.