Back to list
Lv.2

Unit Test

Unit Testing

A test that checks whether the smallest individual pieces of a program work correctly.

In Simple Terms

A unit test is a way to check that each individual piece works correctly before you put the whole program together. For example, if you're building a calculator app, you might pull out just the "addition" feature and check that 1 plus 1 really does equal 2. It's used to automatically and repeatedly test whether small pieces are working the way they were designed to.

Behind the Name

In everyday English, a "unit" is a single, individual item — one piece considered on its own, separate from the group it belongs to. That's exactly the idea behind a unit test: it pulls out one of the smallest pieces that make up a program and checks it all by itself, apart from everything else.

Take a Closer Look!

A unit test is a test that checks whether the smallest individual pieces making up a program work correctly on their own.
In programming, these smallest pieces usually mean "functions" that perform a specific calculation, or "methods" that bundle together a specific piece of processing.
Since it's hard to hunt down problems after everything has already been assembled, teams test things piece by piece first and build up quality from there.

Roughly speaking, it's like checking that every screw and gear was made correctly before installing it into a machine.
In real-world software development, this kind of testing is often automated, so it runs over and over again automatically every time the code gets rewritten.
By making it easier to catch problems at the individual-piece level early on, unit testing helps prevent serious failures from showing up later, once the whole system is complete.

CategoryProgramming