Skip to content

Unit Tests

testingunit tests

Unit testing is checking the smallest parts of a program, like single functions or methods, to make sure they work correctly by themselves.

How it works

A developer writes little test programs that call the function with some input and check if the output is what’s expected. If the result is wrong, the test fails, showing that something in that unit is broken. Unit tests are usually fast and run often during development.

Analogy

unit tests Think of building a car. Before putting everything together, you test each piece alone - the brakes, the engine, the lights. If each part works fine on its own, you have more confidence when combining them later.

unit tests