Introduction
Tests help check if your code works correctly. Writing basic test functions lets you find mistakes early and fix them easily.
When you want to check if a function returns the right answer.
When you change code and want to make sure nothing else breaks.
When you want to share your code and prove it works.
When you want to automate checking many parts of your program.
When you want to learn how your code behaves with different inputs.