التغطية وحدودها
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
read a coverage report and not be fooled by it.
الموضوعات المخطط لها
- Coverage tools (for example JaCoCo) show which lines and branches ran during tests.
- Low coverage shows untested code; high coverage does not show tested behavior.
- A test with no assertions gives coverage and no protection.
- Mutation testing changes your code on purpose; if tests still pass, the mutant "survived" and the test is weak.
- Use coverage to find gaps, not as a target to hit.
تفاصيل المخطط المبدئي
عرض عملي
a method isAdult(age) with a test that calls it and asserts nothing: 100% line coverage, zero protection. Then a mutation (>= to >) survives.
اختبر فهمك
Can 100% coverage coexist with a bug?
أظهر الإجابة
Yes; running a line is not checking its result.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.