by zulgan · 6y ago · 0 comments
TLDR:
* test your core, make sure your core is strong
* don't test your http api
* don't mock
* don't test writing and reading from the database
* don't complicate your code to make it testable
* ... unless you deem fitHow are you meant to write a unit test for a class without mocking out external dependencies? Wouldn't that make it an integration test?
Don't mock things that are already in your codebase. Use the actual object.
Common argument against this I've heard is "But then when something goes wrong it is harder to figure out where the problem is" - I have never actually experienced this myself, but I have, very often, experienced being reluctant to do any refactoring because I'd have to rip up all the unit tests because they are testing only implementation details
The rest just seem arbitrary. Can you make a change and be confident it works ? The last point sums up everything. "Use your best judgement"