I've always been told that unit tests are supposed to be implementation independent. This makes perfect sense to me - if the implementation of a function changes, it should still meet its API contract and thus the unit tests shouldn't need to be changed.
However, this seems to conflict with the idea of mocking. If I need to mock external dependencies, this immediately makes my tests dependent on my implementation. If I were to use different dependencies, I'd have to change the mock code in my unit tests. Is it impractical/unreasonable to make all unit tests entirely implementation independent?
Aucun commentaire:
Enregistrer un commentaire