Why create unit tests?
There are many types of tests you will want to run on a production app. These include unit tests (testing one small part of an app – typically, a method), integration tests (how well the parts of the program run together), UI tests (making sure that interacting with the UI acts as expected), and end-to-end tests (making sure the entire program works as expected).
Unit tests are a critical part of this process and are created for every method and every unit of logic. In fact, multiple tests are typically created for each unit, so that you can test the happy path, the sad path, and corner conditions.
The happy path is when the data is as expected. The sad path is when the data is predictably wrong (for example, the user does not enter a required field).
Corner conditions (also called edge cases) are those situations that are unlikely to happen but might (for example, the user enters 123
as the username).
A key benefit of unit tests is that they...