Knowledge Maxxing
← Back to topic library
Dev MaxxingIntermediateTesting60 sec

Unit test

A unit test checks that one small, isolated piece of code, like a single function, behaves correctly for a given input.

What matters

Because unit tests check small pieces in isolation, they run quickly and pinpoint exactly where a bug lives, rather than only showing that something, somewhere, is broken.

Example

A unit test for an 'add(a, b)' function might check that 'add(2, 3)' returns exactly 5.

Common misconception

A unit test is not meant to verify how multiple parts of a system work together; that broader check is what integration tests are for.

Recall question

Why do unit tests pinpoint bugs more precisely than testing a whole system at once?

Keywords and related concepts

unit testisolated testingsoftware testingintegration test

Related topics

Integration test
Dev MaxxingIntermediate
Test double
Dev MaxxingIntermediate