كل التخصصاتالتقنية · مقابلة عمل

الاختبار

تدور مقابلات الاختبار حول الحكم السليم: ماذا تختبر، وإلى أي عمق، وماذا تفعل عندما لا يمكن الوثوق بالاختبارات. تدرّب على قول هذه الإجابات بصوت عالٍ بنية واضحة.

كلمات → عبارات → جمل → تحدث

جرّب SpeakRole ↗
مقابلة عملالاختبار
V

How do you decide what to cover with unit tests versus integration tests?

0:18
سؤال المقابل

الاختبار

يريد المحاورون في وظائف المطورين وضمان الجودة أن يروا عقلية الجودة: تفكر فيما قد يسوء، وفي احتمال حدوثه، وفي كيفية اكتشافه مبكرًا. الأدوات أقل أهمية من الاستدلال. المرشح الذي يشرح لماذا يوجد الاختبار أقوى ممن يسمّي خمسة أطر عمل.

قدّم كل إجابة في ثلاث خطوات: تعريف قصير، ومثال من مشروع حقيقي، والمفاضلة. في الاختبار يكاد يكون لكل قاعدة استثناء، وقولك ذلك يُظهر أنك عملت مع مجموعة اختبارات حقيقية ولم تقرأ عنها فقط.

  • ✓كلمات → عبارات → جمل → تحدث
  • ✓معنى الإجابة
  • ✓اللغة

أكثر الأسئلة تكرارًا ونماذج الإجابات

What is the test pyramid, and why does it matter?

ما هرم الاختبارات (test pyramid)، ولماذا يهم؟

ما الذي يريد المحاور سماعه. فكرة وجود اختبارات كثيرة وسريعة في القاعدة وقليلة وبطيئة في القمة، مع السبب: الكلفة والسرعة ووضوح أسباب الفشل.

نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍ

The test pyramid is a model for balancing tests. At the bottom there are many fast unit tests, in the middle fewer integration tests, and at the top a small number of end-to-end tests through the real interface. The reason is cost. Unit tests run in milliseconds and point to the exact problem. End-to-end tests are slow, fragile and harder to debug, but they check that the whole system works. If a team has mostly end-to-end tests, the feedback is slow and the suite becomes unreliable. I use the pyramid as a guide, not as a law. For a service that is mostly integration with a database, I may write more integration tests.

What is the difference between a unit test and an integration test, and when do you use a mock?

ما الفرق بين اختبار الوحدة (unit test) واختبار التكامل (integration test)، ومتى تستخدم mock؟

ما الذي يريد المحاور سماعه. تعريفات واضحة، وقاعدة لما يُستبدل بـ mock، وخطر الإفراط في استخدام الـ mocks.

نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍ

A unit test checks one small piece of logic, like a function or a class, in isolation. It is fast and does not need a network or a database. An integration test checks that several parts work together, for example my code and a real database. I use a mock or a stub to replace a dependency that is slow, random or outside my control, like a payment gateway or the clock. But I do not mock everything. If a test only checks that my mock was called, it proves little and breaks whenever I refactor. For the database layer, I prefer a real database in a container, because it finds real problems, such as a wrong query.

What is a flaky test, and how do you deal with it?

ما الاختبار المتقلّب (flaky test)، وكيف تتعامل معه؟

ما الذي يريد المحاور سماعه. الأسباب المعتادة، وطريقة لإيجاد السبب الحقيقي، وسياسة تحمي الفريق من تجاهل حالات الفشل.

نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍ

A flaky test sometimes passes and sometimes fails on the same code. It is dangerous, because people stop trusting the suite and start ignoring red builds. The common causes are fixed waiting times, shared state between tests, random or time-based data, and unstable external services. First I reproduce the problem, by running the test many times or in a different order, and I read the logs. Then I fix the cause: wait for a condition instead of sleeping, isolate the data, control the clock. If I cannot fix it quickly, I quarantine the test and create a ticket, so it does not block everyone. I never just add a retry and forget it.

How do you manage test data?

كيف تدير بيانات الاختبار؟

ما الذي يريد المحاور سماعه. اختبارات معزولة، وإنشاء بيانات مقروء، واهتمام بالخصوصية عندما تدخل بيانات حقيقية.

نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍ

Good test data is realistic, isolated and easy to understand. For unit tests, I create the data inside the test with small builders or factory functions, so the reader sees what matters. For integration and end-to-end tests, each test should create the data that it needs and clean up after itself, or run in a transaction that is rolled back, so tests do not depend on each other. I avoid sharing one big database dump, because nobody knows what is inside, and one change breaks many tests. I never copy real customer data into a test environment without anonymising it, because of privacy rules.

What is test-driven development, and do you use it?

ما التطوير المدفوع بالاختبار (TDD)، وهل تستخدمه؟

ما الذي يريد المحاور سماعه. دورة red وgreen وrefactor، وفوائد حقيقية، ورأي صادق في أين يناسب وأين لا يناسب.

نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍ

TDD means test-driven development. I write a failing test first, then the smallest amount of code that makes it pass, and then I refactor while the tests stay green. This is the red, green, refactor cycle. The benefit is that I think about the behaviour and the interface before the implementation, and I get a safety net for later changes. I find it most useful for business logic and for bug fixes: I first write a test that reproduces the bug. I use it less for exploratory work, like a new user interface, where I do not yet know what I am building. For me, it is a tool, not a rule.

كيف تنطق المصطلحات الأساسية

mock
مُوكْ (على وزن «كْلُوكْ»)
flaky
فْلَيْكِي
regression
رِغْرِشِن
fixture
فِكْسْتْشَر
assertion
أَسِرْشِن
coverage
كَڤَرِج
deterministic
دِتِرْمِنِسْتِك

عبارات مفيدة للإجابة

  • I would test the behaviour, not the implementation.كنت سأختبر السلوك لا التنفيذ.
  • First I write a failing test that reproduces the bug.أولًا أكتب اختبارًا فاشلًا يعيد إنتاج الخطأ.
  • I would mock only what I do not control.كنت سأستخدم mock لما لا أتحكم فيه فقط.
  • What is the risk if this fails in production?ما الخطر إذا فشل هذا في بيئة الإنتاج؟
  • The test should fail for one reason only.ينبغي أن يفشل الاختبار لسبب واحد فقط.
  • I would make the test deterministic first.كنت سأجعل الاختبار حتميًّا (deterministic) أولًا.
  • That belongs in a unit test, not an end-to-end test.هذا مكانه اختبار وحدة، لا اختبار من طرف إلى طرف (end-to-end).

أخطاء شائعة

  • ذكر "90 percent coverage" دليلًا على الجودة. التغطية تُظهر أي الأسطر نُفِّذت، لا هل تفحص الاختبارات شيئًا مفيدًا. قل ما الذي تحميه اختباراتك.
  • قول "I made a test" أو "I did a bug". التراكيب المعتادة هي "write a test" و"run the tests" و"find a bug" و"fix a bug". احفظها عبارات جاهزة ولا تترجم الفعل من العربية.
  • وصف الاختبار بأنه «التنقل بالنقر في التطبيق». تحدث عن المخاطر والأتمتة ومكان كل نوع من الاختبارات.
  • إلقاء اللوم على الآخرين، مثل "developers write bad code" أو "QA is too slow". الإجابة القوية تُظهر ملكية مشتركة للجودة.
  • ادعاء أنك تختبر كل شيء. لا أحد يستطيع ذلك، فاشرح كيف تختار: بحسب المخاطر والأثر وعدد مرات تغيّر الكود.

الأسئلة الشائعة

هل أحتاج إلى معرفة إطار اختبار محدد؟

سمِّ الإطار الذي استخدمته، مثل JUnit أو pytest أو Jest، واشرح كيف نظّمت الاختبارات به. المفاهيم مثل العزل والـ mocks وبيانات الاختبار واحدة في كل إطار، وهي ما يهتم به المحاورون أكثر.

كيف أُظهر عقلية ضمان الجودة في المقابلة؟

تحدث عن المخاطر والمستخدمين: ما الذي قد يسوء، وما أثره، وكيف ستكتشفه مبكرًا. اذكر الحالات الحدية والاختبار الاستكشافي (exploratory testing) وتقارير الأخطاء الواضحة مع خطوات إعادة الإنتاج. وتنجح قصة قصيرة عن خطأ وجدته قبل الإطلاق.

ماذا لو طُلب مني كتابة حالات اختبار في الحال؟

فكّر بصوت عالٍ واتبع ترتيبًا بسيطًا: الحالة العادية، والقيم الحدية، والمدخلات الفارغة أو غير الصالحة، وحالات الفشل. قول هذه الفئات بصوت عالٍ يُظهر بنية في تفكيرك، حتى لو لم يتسع الوقت لكتابة كل حالة.

قراءة الإجابة ليست مثل قولها. تدرّب على كل سؤال بصوت عالٍ، ثم قارن معنى إجابتك ولغتها بالنموذج.

جرّب SpeakRole ↗

موضوعات أخرى في هذا المجال