Debugging your functions is not enough to guarantee that your code reacts appropriately to all the possible scenarios in which it is involved. Furthermore, you cannot automatically repeat the debug procedures every time part of your code changes.
Unit testing helps you. You can run your code automatically and consistently in a manner, covering all possible scenarios that your code might encounter.
Before we look at how to implement unit tests for your functions, it is important to clarify some definitions about unit testing.
Unit testing is a particular type of test where individual units/components of your code are tested. The purpose of the unit test is to validate that the behavior of a component is exactly the behavior of your design.
Unit testing is the first type of test that you execute in the software development pipeline, and, generally...