Enhetstestning verifierar individuella enheter av kod (funktioner, metoder, klasser) i isolering — kontrollerar att varje liten del fungerar korrekt på egen hand. Enhetstester är snabba, fokuserade och bildar grunden för en bra teststrategi.
Vad ett enhetstest är
A UNIT test verifies the smallest testable piece (a function/method) in ISOLATION:
→ test ONE thing; give inputs, check the output/behavior
→ ISOLATED from dependencies (database, network, other units) — mock/stub those
→ FAST (no real I/O), focused, deterministic
