مصفوفة سيناريوهات لكل نقطة نهاية
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
list the cases an endpoint needs before writing tests.
الموضوعات المخطط لها
- For each endpoint list: success, validation failure, unauthenticated (401), unauthorized (403), not found (404), conflict or business-rule failure.
- Write the matrix as a table first; each row becomes a test.
- Check the error body shape too, not just the status code.
- Add boundary data: empty, too long, negative, duplicate.
- Keep the matrix in the repository next to the tests.
تفاصيل المخطط المبدئي
عرض عملي
a matrix for POST /api/orders: valid (201), empty cart (400), no token (401), other user's cart (403), unknown product (404), out of stock (409).
اختبر فهمك
Which two status codes separate "not logged in" from "not allowed"?
أظهر الإجابة
401 and 403.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.