Testing and maintenance
مُقدَّم
19:05
دورة حياة تطوير البرامج
خلل برمجي صغير، إذا تسرب إلى الإصدار النهائي، قد يكلف الكثير لإصلاحه — أكثر بكثير من اكتشافه مبكرًا. لهذا السبب لا نبدأ مجرد كتابة الأكواد. بل نتبع…
سرد باللغة الإنجليزية · ترجمة نصية بالإنجليزية و中文 يمكنك التبديل بينهما
في هذا الدرس
| English | المعنى |
|---|---|
| code/kəʊd/ | Instructions written in a programming language for a computer to follow. |
| 16-bit integer | A whole number stored using 16 binary digits. |
| conversion/kənˈvɜːʃn/ | The process of changing a value from one data type to another. |
| overflowed | Describes a value that was outside the range its storage could represent. |
| run-time error/rʌn taɪm ˈerə/ | خطأ وقت التشغيل |
| routine/ruːˈtiːn/ | A set of instructions that performs a particular task within a program. |
| test data/test ˈdeɪtə/ | Data chosen to check whether a program works as expected. |
| testing/ˈtestɪŋ/ | Running a program with chosen inputs to check that it gives the expected outputs. |
| syntax error/ˈsɪntæks ˈerə/ | خطأ في بناء الجملة |
| keyword/ˈkiːwɜːd/ | A word with a fixed meaning in a programming language or pseudocode. |
| translation/trænˈsleɪʃn/ | Expressing the meaning of a message or text in another language. |
| array index | A whole number that identifies the position of an item in an array. |
| exception/ekˈsepʃn/ | An event that signals an error or unusual condition while a program runs. |
| logic error/ˈlɒdʒɪk ˈerə/ | خطأ منطقي |
| loop/luːp/ | A structure that repeats a sequence of instructions. |
| conditions/kənˈdɪʃnz/ | A requirement or circumstance that affects what happens or whether something is true. |
| tracing/ˈtreɪsɪŋ/ | The process of following a program step by step and recording variable values. |
| translator/trænˈsleɪtə/ | A program that changes code into a form a computer can execute. |
| dry run/draɪ rʌn/ | تشغيل جاف |
| variable/ˈveərɪəbl/ | A quantity or named value that can change or take different values. |
| trace table/treɪs ˈteɪbl/ | A table recording variable values and outputs as an algorithm's steps are followed. |
| walkthrough/ˈwɔːkθruː/ | المراجعة |
| White-box testing/waɪt bɒks ˈtestɪŋ/ | Testing that uses the internal structure of code to design tests. |
| statement/ˈsteɪtmənt/ | A line of code that tells a program what to do. |
| branch/bræntʃ/ | A path of instructions chosen according to a condition or value. |
| Black-box testing/blæk bɒks ˈtestɪŋ/ | Testing that uses the specification to design tests without examining the code. |
| specification/ˌspesɪfɪˈkeɪʃn/ | A description of what a program must do and the requirements it must meet. |
| Integration testing/ˌɪntɪˈɡreɪʃn ˈtestɪŋ/ | Testing combined modules to check that they work together correctly. |
| modules/ˈmɒdjuːlz/ | Separately organised program components that perform defined tasks and communicate through interfaces. |
| interfaces | Points where modules connect and exchange data or commands. |
| stub/stʌb/ | الرمز الوهمي |
| alpha testing/ˈælfə ˈtestɪŋ/ | اختبار ألفا |
| beta testing/ˈbiːtə ˈtestɪŋ/ | اختبار بيتا |
| Acceptance testing/əkˈseptəns ˈtestɪŋ/ | Testing by the customer against requirements to decide whether a product is suitable. |
| test strategy/test ˈstrætədʒi/ | استراتيجية الاختبار |
| test plan/test plæn/ | خطة الاختبار |
| expected output/ekˈspektɪd ˈaʊtpʊt/ | The result a test should produce if the program works correctly. |
| actual output | The result a program produces when a test is run. |
| expected result | |
| Normal data/ˈnɔːml ˈdeɪtə/ | Typical valid values inside the range, which should be accepted and processed correctly. |
| Abnormal data/əbˈnɔːml ˈdeɪtə/ | Values that should be rejected, out of range or the wrong type. |
| Extreme data/ekˈstriːm ˈdeɪtə/ | The smallest and largest values that a program should accept. |
| Boundary data/ˈbaʊndəri ˈdeɪtə/ | Values at and just outside the edges of the accepted range. |
| Corrective maintenance/kəˈrektɪv ˈmeɪntənəns/ | The process of fixing faults found in software after release. |
| Adaptive maintenance/əˈdæptɪv ˈmeɪntənəns/ | The process of changing software to keep it working in a changed environment. |
| operating system/ˈɒpəreɪtɪŋ ˈsɪstəm/ | System software that manages hardware resources and provides services for applications. |
| API/ˌeɪ piː ˈaɪ/ | A set of rules that allows one program to use another program's services. |
| Perfective maintenance/pəˈfektɪv ˈmeɪntənəns/ | The process of improving software that already works after its release. |
| algorithm/ˈælɡərɪθəm/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| data flow | The movement of data through the different parts of a program. |
| subroutine/ˈsʌbruːtiːn/ | A named set of instructions that performs a task when called. |
| caller/ˈkɔːlə/ | The program or module that asks another module to run. |
| parameter list | The ordered list of variables that receive values when a subroutine is called. |
| data structure/ˈdeɪtə ˈstrʌktʃə/ | A way of organising and storing data to support particular operations. |
| regression testing/rɪˈɡreʃn ˈtestɪŋ/ | اختبار الانحدار |
ثلاثون-seven ثانية
- On 4 June 1996 the first Ariane 5 rocket lifted off from French Guiana. Thirty-seven seconds later it veered off course and destroyed itself. The payload was four satellites worth $370 million.
- السبب كان سطرًا واحدًا من الكود، أعيد استخدامه من أريان 4، قام بتحويل رقم 64-بت إلى عدد صحيح 16-بت. طار أريان 5 بسرعة أكبر، وكان الرقم أكبر، مما أدى إلى تجاوز النطاق (overflow) في التحويل: وهو خطأ وقت التشغيل في روتين لم يكن مطلوبًا حتى بعد الانطلاق.
- لم يتم اختبار الكود أبدًا مع بيانات طيران أريان 5. لم يختر أحد بيانات اختبار في حدود الصاروخ الجديد القصوى.
- الدرس المستفاد هنا هو أنواع الأخطاء الثلاثة، وطرق الاختبار، وكيفية اختيار بيانات الاختبار، وكيف يُحافظ على برنامج حي بعد إطلاقه.

ثلاثة أنواع من الأخطاء
- خطأ الصياغة يكسر قواعد اللغة: قوس مفقود، أو كلمة مفتاحية مكتوبة بشكل خاطئ. يُكتشف عند الترجمة، لذلك لن يعمل البرنامج حتى يتم إصلاحه.
- خطأ وقت التشغيل يحدث أثناء تشغيل البرنامج: القسمة على صفر، ملف غير موجود، أو مؤشر مصفوفة خارج النطاق. ينهار البرنامج أو يرفع استثناءً؛ والإصلاح يتطلب إجراء فحص قبل العملية الخطرة.
- خطأ المنطق يسمح للبرنامج بالعمل وإنتاج نتائج خاطئة:
+لـ-، حلقة بإزاحة بمقدار واحد (off-by-one)، أو شروط مرتبة بشكل خاطئ. لا يوجد ما ينبه عليه؛ فقط الاختبار والتتبع يكشف عنه.

يُكتشف عند الترجمة، يُكتشف وقت التشغيل، يُكتشف فقط في المخرجات
Match each kind of error to how it shows up.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Syntax = caught at translation; logic = wrong output; run-time = crash while running.
مثال محلل: إيجاد الأخطاء وتصحيحها
Total ← 0
FOR i ← 1 TO Count
Total ← Total + Marks[i]
NEXT i
Average ← Total / Count
IF Average > 50 THEN
OUTPUT "Pass"
- صياغة: الـ
IFلا يحتوي علىENDIF. المترجم يرفضه. وقت التشغيل: إذا كانCountيساوي 0 تفشل عملية القسمة؛ احفظه باستخدامIF Count > 0 THEN. منطق: إذا كانت الدرجة 50 أو أكثر، يفشل> 50طالباً حصل على 50 بالضبط؛ يجب أن يكون>= 50. - سمِّ النوع، واشرح لماذا هو من هذا النوع، وقدم التصحيح. ثلاثة أجزاء، ثلاث درجات.
A program divides a total by the number of entries and crashes when the input file is empty. This is a:
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Division by zero happens while the program runs and stops it. A guard such as IF Count > 0 fixes it.
طرق الاختبار: قراءة الكود
- التشغيل الجاف يتتبع الكود على الورق، حيث يُكتب قيمة كل متغير في جدول التتبع بعد كل سطر.
- المراجعة الجماعية هي مراجعة فريق: يشرح المبرمج الكود سطراً بسطر بينما يبحث الزملاء عن الأخطاء.
- اختبار الصندوق الأبيض يصمم الاختبارات بناءً على البنية الداخلية للكود، بحيث يتم تغطية كل جملة، وكل فرع، وكل حلقة. أما اختبار الصندوق الأسود فيصمم الاختبارات من المواصفات فقط: إدخال المدخلات، ومقارنة المخرجات بما كان متوقعاً، دون النظر إلى الكود.

نظر من الخارج إلى الداخل، أو نظر من الداخل إلى كل مسار
Designing test cases from the specification only (inputs and expected outputs), ignoring the code inside, is called ______-box testing.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Black-box tests from the spec; white-box uses the code's internal structure to cover statements and branches.
طرق الاختبار: التجميع والإطلاق
- اختبار التكامل يجمع الوحدات التي تم اختبارها بشكل منفصل ويختبر الواجهات بينها. الوحدة الوهمية (stub) تحل محل وحدة لم تُكتب بعد، ترجع قيماً ثابتة حتى يمكن اختبار باقي النظام تنازلياً.
- اختبار ألفا α يُجرى داخلياً بواسطة المطورين قبل الإطلاق. اختبار بيتا β يوفر مجموعة محدودة من المستخدمين الحقيقيين البرنامج في بيئتهم الخاصة.
- اختبار القبول يُجرى من قبل العميل وفقاً للمتطلبات، لتحديد ما إذا كان المنتج مناسباً لغرضه.
Software process lab
Classify development examples by the stage or tool they belong to.
مثال محلل: أي طريقة لأي موقف
- وحدة التقارير مكتملة لكن وحدة قاعدة البيانات التي تستدعيها لم تُكتب بعد: اختبرها باستخدام وحدة وهمية ترجع بيانات ثابتة.
- وحدتان تمران باختباريهن الخاصين لكنهما تفشلان عندما تكون مخرجات إحداهما مدخلات للثانية: اختبار تكامل للواجهة.
- البرمجيات مكتملة؛ تريد الشركة اكتشاف الأخطاء في ظروف حقيقية قبل الإطلاق العام: الاختبار التجريبي من قبل مجموعة محدودة من المستخدمين.
- يقرر العميل الدفع: اختبار القبول مقابل المتطلبات المتفق عليها. سمِّ الطريقة و ما هي لغايتها.
Match each situation to the testing method it needs.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Stub for a missing part, beta for real users, acceptance for the customer, integration for the joins.
استراتيجية الاختبار وخطة الاختبار
- استراتيجية الاختبار هي النهج على المستوى العالي: أي أنواع من الاختبارات ستُجرى، بواسطة من، ومتى، وما الذي يجب أن يمر قبل المرحلة التالية.
- خطة الاختبار هي القائمة التفصيلية للاختبارات. لكل اختبار: الغرض، بيانات الإدخال، المخرجات المتوقعة، وعمود للمخرجات الفعلية عند تشغيل الاختبار.
- الاختبار بدون نتيجة متوقعة ليس اختباراً. إنه يُظهر فقط ما فعله البرنامج، لا ما إذا كان ذلك صحيحاً أم لا.
A test plan lists, for each test, the input data and the expected output.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Purpose, input, expected output and a column for the actual output. The strategy is the high-level approach; the plan is the detailed list.
اختيار بيانات الاختبار
- بيانات عادية: قيم صالحة نموذجية داخل النطاق، والتي يجب قبولها ومعالجتها بشكل صحيح.
- بيانات غير عادية: قيم يجب رفضها، خارج النطاق أو من النوع الخاطئ.
- بيانات متطرفة: أكبر وأصغر القيم التي لا تزال مقبولة، عند حواف النطاق. بيانات الحدود: الأزواج التي تمتد عبر كل حافة، وهي القيمة المتطرفة المقبولة والقيمة المرفوضة التي تقع مباشرة خارجها، حيث تختبئ أخطاء الانزياح بمقدار واحد.

داخل، خارج، وعلى الخط مباشرة
For a field that accepts marks 0–100, which are the boundary test values?
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Boundary data sits at the edges of the valid range (and just outside) — where off-by-one errors hide.
مثال محلول: بيانات الاختبار لدرجة من 0 إلى 100
| النوع | البيانات | النتيجة المتوقعة |
|---|---|---|
| عادي | 50، 75 |
مقبول ومُعالَج |
| غير عادي | -10، 200، "abc" |
مرفوض: خارج النطاق أو نوع خاطئ |
| متطرف | 0، 100 |
مقبول: أصغر وأكبر قيمة صالحة |
| حدودي | -1 و0، 100 و101 |
-1 مرفوض، 0 مقبول؛ 100 مقبول، 101 مرفوض |
- كل صف يحتاج إلى النتيجة المتوقعة؛ جدول المدخلات وحده يحصل على نصف الدرجات. القيم المتطرفة مقبولة:
-1هو حدودي وليس متطرفاً.

A field accepts marks from 0 to 100. Which values are extreme test data? Select جميعها that apply.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Extreme values are the smallest and largest still accepted. -1 is rejected, so it is boundary or abnormal; 50 is normal.
الصيانة
- معظم تكاليف دورة حياة البرنامج تُنفق بعد الإطلاق. الصيانة التصحيحية تصلح الأخطاء التي يتم اكتشافها أثناء الاستخدام.
- الصيانة التكيفية تحافظ على عمل البرنامج في بيئة متغيرة: نظام تشغيل جديد، واجهة برمجة تطبيقات جديدة، تغيير في القانون.
- الصيانة التحسينية تحسن برنامجاً يعمل بالفعل: أداء أسرع، ميزة جديدة طلبها المستخدمون. قد يحتاج البرنامج إلى جميع الأنواع الثلاثة طوال عمره.

إصلاحه، الحفاظ على عمله، جعله أفضل
Corrective maintenance fixes faults, perfective maintenance improves features, and adaptive maintenance keeps the software working in a changed environment.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Three maintenance types: corrective (fix bugs), perfective (enhance), adaptive (new OS/hardware/rules).
A payroll program is changed because the tax law changed. Which kind of maintenance is this?
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
The program was not faulty and is not being improved; its environment changed. That is adaptive maintenance.
تعديل برنامج موجود
- اقرأ الكود الموجود حتى تفهم الخوارزمية وتدفق البيانات. حدد مكان التعديل: أي دالة فرعية، وأي أسطر.
- قم بالتعديل كـ صغير قدر الإمكان؛ لا تقم بإعادة كتابة كود يعمل. حدّث كل جزء مرتبط: كل مستدعٍ لقائمة بارامترات مُعدَّلة، وكل روتين يستخدم هيكلاً للبيانات المُعدَّل.
- اختبر السلوك الجديد و القديم: اختبار الانحدار يتحقق من عدم تعطل أي شيء كان يعمل سابقاً. ثم وثّق التعديل.
After changing a program, regression testing checks that:
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Regression testing re-runs old tests to confirm existing behaviour still works after a change.
Put the steps of amending an existing program in order.
الصعوبة 3/5 · 200 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Understand, locate, change small, propagate, test everything, record. Skipping the regression test is how a fix breaks something else.
تم تصحيح هذه البطاقة، لذلك تظهر باللغة الإنجليزية حتى يتم تحديث ترجمتها.
Marks that slip away
- Extreme is accepted; abnormal is rejected.
0and100are extreme;-1and101are boundary values on the rejected side. - A logic error can produce wrong output or lead to a run-time error, such as an out-of-range array access.
- Alpha is in-house; beta is real users outside. A stub replaces a missing module; it is not a test method for finished code.
- A test plan row without an expected output 预期输出 earns nothing. Regression testing follows every change.
لقد فهمت الأمر
- أخطاء البناء النحوي توقف الترجمة · أخطاء وقت التشغيل تُسبب انهيار البرنامج运行时 · أخطاء المنطق تعمل وتعطي مخرجات خاطئة، تُكتشف فقط بالاختبار
- طرق: التشغيل الجاف، المراجعة, صندوق أبيض (من الكود), صندوق أسود (من المواصفات), تكامل (الواجهات, مع قطع وهمية للوحدات المفقودة), ألفا (داخلي), بيتا (مستخدمون حقيقيون), قبول (العميل)
- بيانات الاختبار: عادي مقبول، غير عادي مرفوض، متطرف هو حواف القبول، حدودي على جانبي كل حافة؛ كل اختبار له نتيجة متوقعة
- الصيانة: تصحيحية للإصلاحات، تكيفية للتحديث مع البيئة، تحسينية للتحسين؛ عدّل صغيراً، حدّث المستدعين، اختبر الانحدار
ما المشكلة؟ لا يرى ذلك سوى فريق الموقع.