SELF-GUIDED BA PRACTICE Packages available · Access after confirmed paymentSee packages ↗

Business analysis glossary

Unit Testing

What it is

Unit testing is testing the smallest pieces of code, such as a single function or class, in isolation, usually with automated tests written by developers. Each test checks that, for a given input, the unit returns the expected output or behaviour.

Why it matters

Unit tests catch mistakes early, when they are cheapest to fix, and make it safer to change code later. Analysts do not usually write them, but clear business rules with examples, such as a decision table for a discount, make it much easier for developers to write good unit tests.

Example

The analyst gives developers a decision table for late fees: no fee within five days, a flat fee from six to fifteen days and a percentage after that. The developer writes one unit test for each row and for the boundary days, five, six, fifteen and sixteen, before writing the fee function.

CHECK BEFORE CONTINUING

Keep your work safe