Kendrick S. answered 05/25/25
Amazon Software Engineer | Ex-Google | CS Tutor & UC Berkeley Alum
Tests are extremely important. There are multiple types of tests you can introduce: unit tests (meant to test single functions), integration tests (meant to test whole components), and end-to-end tests/UI tests (use a physical device to make sure everything works).
Testing is less important for a single function on a solo project, but courses are designed to train you for commercial experience. In industry, you will have hundreds of engineers working on large codebases, introducing multiple changes per day. This constant stream of change needs to be validated, and tests will help catch issues before they spread.
Just recently, we had some function from 2021 that I had to update because someone happened to notice that it was missing a REGEX pattern to make sure the strings that get passed to the function were not a security risk. I added the simple validation, but it broke the unit tests! Turns out that this function was used unexpectedly in a very different class, and I had to modify the missing REGEX pattern to keep the code operational.
Without that unit test, I would have introduced a defect.