Is a software development process during which the smallest testable parts of an applications are collectively and independently assessed for operability.
A unit test is a method that tests a unit of behavior represented by an individual class or a function/procedure/method.
-
Core business logic methods / functions
-
High-risk services
-
Utility methods and algorithms
DO NOT
-
Procedures that don't contain any validations ( E.g Models).
-
Configuration (e.g constants, read-only fields, configs, enumerations).
-
Private methods / functions directly.
-
Database queries or multi-threading code.
- Enable safe refactors
- Find bugs quickly and easly
- Save time and money
- Provide code documentation for developers.
- Fast
- Isolate & Independent
- Repeatable : must be deterministic.
- Self-validation : clearly indicates whether it passes or failed
- Thorought and timely