Glossary/Unit Testing
Testing & QA
1 min read
Share:

What is Unit Testing?

TL;DR

Unit testing is the practice of testing individual functions, methods, or classes in isolation from the rest of the system.

Unit testing is the practice of testing individual functions, methods, or classes in isolation from the rest of the system. Unit tests are the foundation of the test pyramid — fast (milliseconds), focused (one assertion per test), and numerous (thousands in a mature codebase).

Unit test characteristics (FIRST): Fast (run in milliseconds), Independent (no shared state between tests), Repeatable (same result every time), Self-validating (pass/fail without human inspection), and Timely (written alongside or before the code).

Tools by language: JavaScript (Jest, Vitest), Python (pytest), Java (JUnit), Go (built-in testing package), Rust (built-in #[test]). Test coverage targets: 80%+ line coverage for business logic, 90%+ for critical financial/security code.

Why It Matters

Unit tests catch 70%+ of bugs before code reaches production. They enable fearless refactoring — change implementation, run tests, confidence that nothing broke. Without unit tests, every change is a risk.

Frequently Asked Questions

What is a unit test?

A test that verifies a single function or class in isolation. Fast (milliseconds), focused (one behavior per test), and numerous (thousands in a mature codebase). The base of the test pyramid.

How much unit test coverage is enough?

80%+ line coverage for business logic, 90%+ for critical paths (payments, auth, security). 100% coverage is often not worth the effort — diminishing returns on testing trivial code.

Related Terms

Need Expert Help?

Richard Ewing is a Product Economist and AI Capital Auditor. He helps companies translate technical complexity into financial clarity.

Book Advisory Call →