Problem Statement
What is the primary purpose of unit tests in CI/CD?
Explanation
Unit tests verify individual units of code (functions, methods, classes) in isolation without external dependencies (databases, APIs, file systems). They are fast (thousands per second), deterministic, and provide immediate feedback on code correctness. Unit tests catch bugs early in development before code integration.
Characteristics: fast execution (milliseconds), isolated (mock external dependencies), focused (test one thing), deterministic (same input always produces same output), independent (tests don't depend on each other or execution order). Example: testing calculation function with various inputs, testing validation logic, testing data transformations.
CI/CD integration: unit tests run on every commit, gate merges (pull request checks), provide code coverage metrics. Fast execution enables running entire suite frequently without slowing development. Test failure blocks pipeline preventing broken code from progressing. Understanding unit testing enables catching bugs early at lowest cost.
