Introduction
Testing helps find mistakes in your code early. It makes sure your program works as expected and keeps it reliable.
When you finish writing a new feature and want to check it works correctly.
Before sharing your program with others to avoid bugs.
When you fix a problem to confirm the fix did not break anything else.
When you update your code to make sure old features still work.
When you want to improve your code safely by testing small parts.