Volver al glosario
TestingPopular

Unit Testing

A software testing method where individual units or components of code are tested in isolation to verify they work correctly.

Definicion

Unit tests verify the smallest testable parts of an application — typically individual functions or methods. They mock external dependencies to isolate the code under test. Good unit tests are: fast (run in milliseconds), independent (no shared state), repeatable (same result every time), and self-validating (clear pass/fail). Popular frameworks include Jest (JavaScript), pytest (Python), JUnit (Java), and Go's testing package.

Por que es importante

Unit tests catch bugs at the source, provide documentation of expected behavior, and enable safe refactoring. Teams with high unit test coverage report 40-80% fewer production bugs. Unit tests also run fast enough to include in every CI pipeline.

Ejemplo

A unit test verifies that a calculateDiscount() function returns 10% off when given a $100 order from a VIP customer, mocking the database calls to customer data.

Terminos relacionados

unit testingwhat is unit testingunit testunit testing definition

Automatiza Code Review con diffray

Sistema de IA multi-agente para code review. Encuentra bugs, vulnerabilidades de seguridad y problemas de arquitectura automaticamente.