News for hackers. Stuff that matters.
Re:Ask HN: What made you change your mind about a programmin... by ht85 on Sunday March 03, 2019 @07:02PM (#19297776)
What you want to spy on are side-effects that are part of the function's contract.

If you have a function that fetches data, you shouldn't test that its hitting the data layer, only that the correct data is returned. This way when you improve the function to not hit the data layer at all under some conditions, your tests will keep passing.

On the other hand, if that function is supposed to log metrics or details about its execution, you should test that ,as it is part of its contract and can't be inferred from the return value.

There are no comments on this comment yet.