Unit Testing
Noun · Development
Definitions
Unit testing is the practice of writing automated tests that verify individual functions, methods, or classes in isolation from the rest of the system. Each test targets a small, specific unit of behavior, typically with external dependencies replaced by mocks or stubs. Unit tests form the base of the testing pyramid: they are fast (milliseconds per test), cheap to maintain, and provide precise feedback about what broke. Popular frameworks include JUnit (Java), pytest (Python), Jest (JavaScript), and xUnit (.NET). A well-tested codebase may have thousands of unit tests that run in seconds, enabling developers to refactor confidently. Unit tests work best for pure logic and algorithms; integration and end-to-end tests cover the gaps where components interact.
In plain English: Testing one small piece of code at a time, in isolation, to make sure each piece works correctly on its own before combining them.
Example: "Each pure function gets a unit test. Integration tests cover how they work together."