What is Unit Testing
Testing individual code modules
Unit Testing is a testing method that verifies individual modules or components of a program in isolation.
Principles
- Isolation — test checks only one module
- Automation — tests run automatically
- Repeatability — result is always the same
- Speed — execution in milliseconds
Popular Frameworks
- Jest (JavaScript/TypeScript)
- PyTest (Python)
- JUnit (Java)
- NUnit (.NET)
- RSpec (Ruby)
AAA Pattern
- Arrange — prepare data
- Act — execute action
- Assert — verify result
Benefits
- Early bug detection
- Code documentation
- Confidence when refactoring
- Faster development