I primarily write unit tests for the following reasons:
- When I write an algorithm, I almost always miss some edge cases. Writing unit tests helps uncover most of them.
- Unit testing forces me to maintain clean function interfaces and design modularly.
While it may sometimes feel tedious, the peace of mind that comes with having passing tests is well worth the effort.