A unit test is a check to ensure that a function works as expected. It is written during the software development process.
- Makes it easier to add a new feature or delete a feature.
- The developer refactors with more confidence.
- Bugs are found earlier during development.
- Makes debugging easier.
- It improves code quality.
- The function/module should contain all input(s) needed as parameters.
- The function/module should return an output.
- Do not test any external module, library or function for example the database, an API etc.