Characteristics of a good unit test:
- Fast. It is not uncommon for mature projects to have thousands of unit tests. Unit tests should take very little time to run. Milliseconds.
- Isolated. Unit tests are standalone, can be run in isolation, and have no dependencies on any outside factors such as a file system or database.
- Repeatable. Running a unit test should be consistent with its results, that is, it always returns the same result if you do not change anything in between runs.
- Self-Checking. The test should be able to automatically detect if it passed or failed without any human interaction.
- Timely. A unit test should not take a disproportionately long time to write compared to the code being tested. If you find testing the code taking a large amount of time compared to writing the code, consider a design that is more testable.