Test Types
Unit Testing
Testing individual components or functions in isolation to verify they work correctly on their own.
Full definition
Unit testing verifies the smallest testable parts of an application — individual functions, methods, or classes — in complete isolation. Unit tests are fast, focused, and form the foundation of the testing pyramid.
Characteristics of good unit tests:
- Fast: Execute in milliseconds
- Isolated: No dependencies on external systems (DB, API, filesystem)
- Repeatable: Same result every time, regardless of environment
- Self-validating: Pass or fail automatically, no manual inspection
- Timely: Written close to the code being tested (ideally before — TDD)
Common unit testing frameworks:
- JavaScript/TypeScript: Jest, Vitest, Mocha
- Python: pytest, unittest
- Java: JUnit, TestNG
- C#: NUnit, xUnit
Unit tests use mocks, stubs, and fakes to isolate the code under test from its dependencies. This allows testing business logic without needing a database or network connection.