"Please write a UT for this change." is one of the most frequent comments I leave in the code review. And I am seeing people tend to write minimum tests just for having something to pass the review.
Well, I kind of understand writing tests is annoying sometimes, but tests are extremely helpful and there are things could help us writing them too. So let's talk about test!
1. "Writing test is so annoying"
"Hey! It compiles! Ship it!"
When talking about writing tests, many people find it annoying for simliar reasons:
- Extra work. Most of time, writing tests is very time consuming. And sometimes, it will take even longer time than development itself.
- The thrill of developing a new feature is usually over after the core logic is done.
- Writing test is a tedious work. And you might not even be able to find a single bug after writing tons of tests.
- We have added a lot of tests for a feature. Then the feature changed, and all the tests have to be rewritten, which greatly slows down the development.
All these questions and complaints are basically because we don't understand the real intention of testing, and finally fall into the misunderstanding of writing test for the sake of writing tests. And when we are forced to do something, we are never going to feel it will benefit us, even if it really does.