اختبار الوحدة يتحقق من وحدات فردية من الكود (الدوال، الطرق، الفئات) بشكل معزول — يفحص أن كل جزء صغير يعمل بشكل صحيح بمفرده. اختبارات الوحدة سريعة ومركزة وتشكل أساس استراتيجية اختبار جيدة.
ما هو اختبار الوحدة
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
