← Back to context

Comment by apothegm

5 hours ago

Unit tests are super useful when first writing a function or class to confirm it does what you think it does.

Then throw away the unit tests and write integration or E2E tests instead. Then you can refactor under the hood while ensuring overall system behavior is as expected.

There are some exceptions where you might want to hang on to a small subset of unit tests. They can be useful for demonstrating how to use an interface or class. They can help support particularly complex bits of logic. If a certain part of your codebase is fragile and regression prone, unit test coverage can help.

Otherwise, they just calcify the code.