In Unit Testing individual components (“units”) of source code are tested in isolation of any other component. As a result the functionality of each individual component can be proven.
Unit Tests are the “foundation” of software testing, as they guarantee that the functionality works as intended - that is: as expressed in the software tests.
Writing code, that is “unit testable” implies that the resulting components “expose their dependencies”. Or vice versa: Code, that has hidden dependencies is not unit-testable in a clean way.
Dependencies in Unit Tests need to be mocked, stubbed, written as test-dummies, etc.
- Fast: Executing Unit Tests is usually very fast, hence usually executed early in Automated Tests
- Vulnerable to re-factoring: Changing the code structure usually requires re-factoring of all unit-tests that pertain to the re-factored code as well
- Only tell you so much: What comes in, comes out - Unit Tests can be written badly in that they give confidence (through existing), but do not actually test anything sensible