انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-044-L05

متى لا نستخدم المحاكاة

  • الدرس 5 من 6
  • Junior
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

recognize over-mocking and choose better options.

الموضوعات المخطط لها

  • Do not mock types you do not own (JDBC, HttpClient); wrap them in your own interface and mock or fake that.
  • Do not mock value objects, simple data classes, or collections; use real ones.
  • A mock that returns another mock signals bad design or a leaky test.
  • Verifying every call ties the test to the implementation.
  • Prefer a fake repository for logic tests; prove the real database in integration tests.
تفاصيل المخطط المبدئي

عرض عملي

a "before" test with eight mocks and twelve verify lines, and an "after" using a fake repository, one mocked gateway, and result assertions.

اختبر فهمك

Why avoid mocking a JDBC Connection?

أظهر الإجابة

You do not own that type; the test would mirror its internals, not behavior.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.