Testing helps undrestanding the code
Do you often find yourself working on a project, where you don’t have any idea what’s going on? Sometimes it is project you wrote several months ago, or you were given a project after someone else and you have to finish it. It takes time to learn how things work
Testing eliminates false assumptions
If you are learning new stuff, you naturally make some assumptions. However, when you don’t fully understand the system, it’s easy to make a false assumption, which will cost you a lot of time. Whenever you have a problem, validate all your assumptions.
Writing few lines of test code doesn’t cost you much time, and it will rapidly increase your confidence. Great bunch of problems that you run into are caused by little things, usually because of false assumptions.
Confidence is important
For every test you write, you will get a little boost of confidence. If you are unsure about how some method works, write a test. Few lines of test code will save you many headaches later. Nothing is too simple for testing, don’t be ashamed. Keep writing tests until you are confident that you fully understand the problem.
It will take little extra time of writing, but you will save a lot of time while reading the code 2 months later.
Examples for other people to learn from
Testing is even more beneficial when you are working in a team. Every test is a living example of how the code should be used. People like examples, because they are easier to learn from.
By testing your code, you not only help yourself, but you also save a lot of time of other people who will have to maintain the project after several months.