Unit Test
Definition
A component test checks a small, delimited unit of software.
A function or module receives defined inputs; the test compares the actual with the expected result. Dependencies are replaced with controlled substitutes if needed.
Simply explained
Like checking a single gear before testing the entire machine.
Why it matters in practice
Errors become visible early and can be rechecked during later changes.
Example from business
Hypothetical example: A test checks whether a pricing function correctly handles discounts and rounding.
Limits and pitfalls
- Tests that only simulate the program code overlook the same logical errors; too many substitutions can conceal real problems.
Origin & history
Component tests are among the foundations of automated software testing.
Use in mid-sized companies
- Secure business rules, conversions, and validation functions.
Frequently asked questions
Do unit tests replace a test of the entire application?
No, the interaction requires additional tests.
Sources
- unittest · Python: unittest –
Editorially reviewed on: