4 ms·
Why would it be of concern? I think mocks have a good place in unit tests. I generally believe the premise of unit tests is to test your code against specific p
by gautamdivgi 10y ago
Why would it be of concern? I think mocks have a good place in unit tests. I generally believe the premise of unit tests is to test your code against specific pre-conditions. If those pre-conditions cannot be created in a unit testing environment then mocks are justified. I would, however, be very way of mocks moving past unit testing and into integration or system testing (or other varieties like failure injection testing, performance testing, etc.). Mocks have their uses & their limitations. Understanding that is key to using them well.
- gohrt 10y ago> If those pre-conditions cannot be created in a unit testing environment then you have technical debt to repay, by making those pre-conditions satisfiable
- wahnfrieden 10y agoIt means that you lose out on a lot of value from your test suite: besides verifying behavior on new code, tests also allow you to confidently refactor existing code. If your tests test implementation via mocking, and break when you refactor your code in ways that preserve the intended behaviors, then you're unable to confidently refactor. Mocks lead you down a path where developers will eventually feel too scared or fatigued to refactor anything substantial.