عرض عملي: إصلاح تسرّب بيانات الاختبار
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
find and fix tests that depend on each other. Prepares JNR-045-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Show two tests that pass alone but one fails when run together.
- Find the cause: both insert the same email, or one counts all rows.
- Run in random order (JUnit method order setting) to reproduce.
- Fix with unique data per test and a cleanup in
@BeforeEach. - Planned mistake: adding
@Transactionalto a test that uses real HTTP and seeing the leak remain; explain why and use cleanup instead. - Run the suite ten times to confirm.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.