13 مثالًا من تطبيقات حقيقية13 examples from real apps
الأبيض: اقرأ الكود والمخطط والمسارات. الأسود: اقرأ المواصفة والفئات والحدود. ثم افتح المثال في المختبر وجرّبه بنفسك.White: read the code, graph and paths. Black: read the spec, classes and boundaries. Then open it in the lab and try it yourself.
0 / 13
1
أرخص سعر في تطبيق مقارنة الأسعارCheapest price in a price-comparison app
التطبيق يجمع أسعار المنتج من عدة متاجر ويعرض الأرخص. هذا مثال المقرّر (أصغر عنصر في مصفوفة) بثوب حديث.The app collects a product’s price from several stores and shows the cheapest. This is the course example (min of an array) in modern clothes.
صندوق أبيض · White boxويب + جوال · Web + MobilewhileifV(G)=3
1
1
2
3
4
5
6
function cheapestPrice(prices) {
let min = prices[0];
let i = 1;
while (i < prices.length) {
if (prices[i] < min) {
min = prices[i];
}
i++;
}
return min;
}
التطبيق يحسب متوسط النجوم (1–5) ويتجاهل القيم غير الصالحة، ويتوقف عند null (نهاية الصفحة المحمّلة). مثال المقرّر «average» مع الشروط المركّبة.The app averages star ratings (1–5), skips invalid values, and stops at null (end of the loaded page). The course “average” example with compound conditions.
صندوق أبيض · White boxجوال · Mobile&&whileV(G)=6
1
2,3
4,5
6
7
8
9
10
11
function averageRating(ratings) {
let i = 0, count = 0, sum = 0, avg;
while ((i < ratings.length) && (ratings[i] !== null)) {
if ((ratings[i] >= 1) && (ratings[i] <= 5)) {
count++; sum += ratings[i];
}
i++;
}
if (count > 0) {
avg = Math.round((sum / count) * 10) / 10;
} else {
avg = null;
}
return avg;
}
عضو، محلي، المبلغ 80. أي مسار؟Member, domestic, subtotal 80. Which path?
4
قفل الحساب بعد محاولات خاطئةAccount lockout after wrong attempts
خدمة المصادقة في تطبيق محفظة: إن كان الحساب مقفلًا نرفض، وبعد 3 محاولات خاطئة نطلب OTP.An e-wallet’s auth service: if the account is locked we refuse; after 3 wrong attempts we require an OTP.
صندوق أبيض · White boxجوال · Mobilenested ifV(G)=4
1
2
3
4
5
6
7
8
9
function loginAttempt(passwordOk, failedBefore, lockedMinutes) {
let result = 'ok', failed = failedBefore;
if (lockedMinutes > 0) {
result = 'locked';
} else if (!passwordOk) {
failed++;
if (failed >= 3) {
result = 'otp-required';
} else {
result = 'wrong-password';
}
}
return result;
}
كلمة مرور خاطئة، محاولتان سابقتان، غير مقفل. النتيجة؟Wrong password, 2 failed before, not locked. Result?
5
كوبونات الخصم بـ switchDiscount coupons with switch
SAVE10 خصم 10%، FREESHIP خصم 5، WELCOME خصم 15 لأول طلب فقط، وأي كود آخر بلا خصم.SAVE10 takes 10% off, FREESHIP takes 5 off, WELCOME takes 15 off on the first order only, any other code nothing.
صندوق أبيض · White boxويب · WebswitchV(G)=5
1
2
3
4
5,6
7
function applyCoupon(total, code, isFirstOrder) {
let discount = 0;
switch (code) {
case 'SAVE10':
discount = total * 0.1; break;
case 'FREESHIP':
discount = 5; break;
case 'WELCOME':
if (isFirstOrder) { discount = 15; }
break;
}
return Math.max(0, total - discount);
}
قوة كلمة المرور في نموذج التسجيلPassword strength in a sign-up form
نقطة للطول ≥ 8، ونقطة لوجود رقم، ونقطة لحرف كبير. ثلاث جمل if متتالية.A point for length ≥ 8, a point for a digit, a point for a capital letter. Three ifs in a row.
صندوق أبيض · White boxويب + جوال · Web + Mobilesequential ifV(G)=4
1
2,3
4,5
6,7
8
function passwordScore(password) {
let score = 0;
if (password.length >= 8) { score++; }
if (/[0-9]/.test(password)) { score++; }
if (/[A-Z]/.test(password)) { score++; }
return score;
}
كم مسارًا كاملًا ممكنًا؟How many full paths are possible?
7
إعادة المحاولة مع breakRetry with break
التطبيق يعيد الطلب عند أخطاء 5xx، والانتظار يتضاعف (1، 2، 4…). يتوقف عند أول رد ناجح.The app retries on 5xx errors with doubling waits (1, 2, 4…). It stops at the first successful response.
صندوق أبيض · White boxجوال · MobilewhilebreakV(G)=3
1
2
3,4
5
6
function totalWait(statuses) {
let wait = 0, delay = 1, i = 0;
while (i < statuses.length) {
if (statuses[i] < 500) { break; }
wait += delay; delay *= 2; i++;
}
return wait;
}
تطبيق توصيل طعام. اختبر رسوم التوصيل بدون رؤية الكود.A food delivery app. Test the delivery fee without seeing the code.
صندوق أسود · Black boxجوال · MobileBVA≥
المواصفة · Specالتوصيل مجاني (0) عندما يكون المبلغ 50 أو أكثر، وإلا فالرسوم 4. المبلغ السالب يعيد error.Delivery is free (0) when the subtotal is 50 or more, otherwise the fee is 4. A negative subtotal returns error.
الفئة · Class
مثال · Sample
سالب (غير صالح)Negative (invalid)
-5
من 0 إلى أقل من 500 up to below 50
20
50 فأكثر50 and above
80
القيم الحدّية · Boundaries
-0.01049.995050.01
#
الملخص · Summary
المدخل · Input
المتوقّع · Expected
TC1
مبلغ صغيرSmall order
subtotal = 20
4
TC2
مبلغ كبيرBig order
subtotal = 80
0
TC3
على الحدّ تمامًاExactly on the boundary
subtotal = 50
0
TC4
تحت الحدّ مباشرةJust below the boundary
subtotal = 49.99
4
TC5
مبلغ سالبNegative subtotal
subtotal = -5
error
الاختبارات 20 و 80 تنجح حتى مع وجود الخطأ. الحدّ 50 هو ما يكشفه.Tests with 20 and 80 pass even with the bug. Only the boundary 50 reveals it.
كم فئة تكافؤ للعمر؟How many equivalence classes does age have?
10
كمية المنتج في السلةItem quantity in the cart
زر «أضف للسلة» يرسل الكمية لخدمة السلة. اختبر الخدمة من الخارج.The “Add to cart” button sends a quantity to the cart service. Test the service from outside.
صندوق أسود · Black boxويب + جوال · Web + MobileEPBVA
المواصفة · Specالكمية من 1 إلى 10 ← added، وأقل من 1 أو أكثر من 10 ← error.A quantity from 1 to 10 → added; below 1 or above 10 → error.
الفئة · Class
مثال · Sample
أقل من 1Below 1
-2
1 إلى 101 to 10
4
أكثر من 10Above 10
15
القيم الحدّية · Boundaries
011011
#
الملخص · Summary
المدخل · Input
المتوقّع · Expected
TC1
كمية عاديةNormal quantity
qty = 4
added
TC2
صفرZero
qty = 0
error
TC3
الحدّ الأدنىMinimum
qty = 1
added
TC4
الحدّ الأعلىMaximum
qty = 10
added
TC5
فوق الحدّOver the maximum
qty = 11
error
القيمة -2 تمثّل الفئة غير الصالحة لكنها لا تكشف الخطأ. الحدّ 0 يكشفه.-2 represents the invalid class but does not reveal the bug. The boundary 0 does.
شاشة إدخال رمز التحقّق في تطبيق بنكي. نختبر قبول الرمز قبل إرساله للخادم.The verification code screen of a banking app. We test which codes are accepted before sending them to the server.
صندوق أسود · Black boxجوال · Mobiletextlength
المواصفة · Specالرمز صالح إذا كان 6 أرقام بالضبط ← valid، وغير ذلك ← invalid.A code is valid if it is exactly 6 digits → valid, otherwise → invalid.
الفئة · Class
مثال · Sample
أقل من 6 أرقامFewer than 6 digits
123
6 أرقامExactly 6 digits
482913
أكثر من 6 أرقامMore than 6 digits
12345678
فيه حروفHas letters
12a456
القيم الحدّية · Boundaries
123451234561234567
#
الملخص · Summary
المدخل · Input
المتوقّع · Expected
TC1
رمز صحيحA correct code
code = "482913"
valid
TC2
5 أرقام5 digits
code = "12345"
invalid
TC3
7 أرقام7 digits
code = "1234567"
invalid
TC4
حرف داخل الرمزA letter inside
code = "12a456"
invalid
الحدود تنطبق على الأطوال أيضًا، لا على الأرقام فقط.Boundaries apply to lengths too, not only to numbers.
أي أطوال تختبر الحدود؟Which lengths test the boundaries?
12
تسعير ساعة الذروة في تطبيق رحلاتRush-hour pricing in a ride app
الأجرة الأساسية 10. في الذروة تُضرب بـ 1.5.The base fare is 10. In rush hour it is multiplied by 1.5.
صندوق أسود · Black boxجوال · MobilerangesBVA
المواصفة · Specالذروة من الساعة 17 إلى 19 (شاملًا) ← 15، باقي الساعات ← 10، والساعة خارج 0–23 ← error.Rush hour is 17 to 19 (inclusive) → 15, other hours → 10, an hour outside 0–23 → error.
الفئة · Class
مثال · Sample
ساعة غير صالحةInvalid hour
25
خارج الذروةOff-peak
10
الذروةRush hour
18
القيم الحدّية · Boundaries
-10161719202324
#
الملخص · Summary
المدخل · Input
المتوقّع · Expected
TC1
صباحًاMorning
hour = 10
10
TC2
بداية الذروةRush hour starts
hour = 17
15
TC3
آخر ساعة ذروةLast rush hour
hour = 19
15
TC4
بعد الذروةRight after rush hour
hour = 20
10
TC5
ساعة غير موجودةAn hour that does not exist
hour = 24
error
مدى داخل مدى: حدود 0–23 وحدود 17–19 كلها تستحق الاختبار.A range inside a range: the edges of 0–23 and of 17–19 all deserve a test.
أي ساعة تكشف خطأ «<= 20 بدل <= 19»؟Which hour reveals “<= 20 instead of <= 19”?
13
قواعد اسم المستخدمUsername rules
منصة ألعاب على الويب تتحقّق من اسم المستخدم عند التسجيل.A web gaming platform validates the username at sign-up.
صندوق أسود · Black boxويب · WebEPtext
المواصفة · Specمن 3 إلى 20 حرفًا، حروف إنجليزية وأرقام و _ فقط، ويجب أن يبدأ بحرف ← ok، وإلا ← invalid.3 to 20 characters, English letters, digits and _ only, and it must start with a letter → ok, otherwise → invalid.
الفئة · Class
مثال · Sample
صالحValid
sara_99
قصير جدًاToo short
ab
طويل جدًاToo long
a_very_long_username_x
رمز غير مسموحForbidden symbol
sara!
لا يبدأ بحرفDoes not start with a letter
9sara
القيم الحدّية · Boundaries
ababca + 19 charsa + 20 chars
#
الملخص · Summary
المدخل · Input
المتوقّع · Expected
TC1
اسم صالحA valid name
username = "sara_99"
ok
TC2
قصيرToo short
username = "ab"
invalid
TC3
رمز !Has !
username = "sara!"
invalid
TC4
يبدأ برقمStarts with a digit
username = "9sara"
invalid
هنا الخطأ ليس على حدّ رقمي: إنها فئة كاملة منسية. لكل قاعدة في المواصفة فئة.Here the bug is not at a numeric edge: a whole class was forgotten. Every rule in the spec deserves its own class.