App Dev Worksheet: Testing
Developer's tip (Expected vs actual): Test case = input + expected result (from the rule). Run the code: actual = expected → pass; otherwise → fail. Always test the edge value: < and <= differ only there.
NameDateTime takenScore ___ / 40
-
1.🧪 How many of these test cases pass?
🚚 Rule: delivery is free (0) when the order is 400 or more; otherwise it costs 40.
function delivery(total) {
if (total >= 400) {
return 0;
}
return 40;
}
Test 1: delivery(300) → expected 40
Test 2: delivery(650) → expected 0
Test 3: delivery(400) → expected 0 -
2.🧪 How many of these test cases pass?
📝 Rule: a quiz is passed with 6 or more right answers.
function result(right) {
if (right >= 6) {
return "Pass";
}
return "Try again";
}
Test 1: result(7) → expected Pass
Test 2: result(6) → expected Pass
Test 3: result(5) → expected Try again - 3.🧪 A test fails when ___. (a) the app is new (b) both are the same (c) actual is not expected (d) the font is big
- 4.🧪 Who else should try an app before release? (a) only the coder (b) nobody (c) real users (d) the app icon
-
5.🧪 One test case fails. Which one?
📝 Rule: a quiz is passed with 8 or more right answers.
function result(right) {
if (right > 8) {
return "Pass";
}
return "Try again";
}
Test 1: result(9) → expected Pass
Test 2: result(5) → expected Try again
Test 3: result(8) → expected Pass (a) Test 3 (b) Test 1 (c) Test 2 -
6.🧪 One test case fails. Which one?
📝 Rule: a quiz is passed with 5 or more right answers.
function result(right) {
if (right > 5) {
return "Pass";
}
return "Try again";
}
Test 1: result(5) → expected Pass
Test 2: result(7) → expected Pass
Test 3: result(3) → expected Try again (a) Test 1 (b) Test 2 (c) Test 3 -
7.🧪 One test case fails. Which one?
🎟️ Rule: a ticket costs 50 for children under 8, and 100 for everyone else.
function price(age) {
if (age <= 8) {
return 50;
}
return 100;
}
Test 1: price(8) → expected 100
Test 2: price(11) → expected 100
Test 3: price(4) → expected 50 (a) Test 3 (b) Test 2 (c) Test 1 -
8.🧪 How many of these test cases pass?
🚚 Rule: delivery is free (0) when the order is 500 or more; otherwise it costs 40.
function delivery(total) {
if (total > 500) {
return 0;
}
return 40;
}
Test 1: delivery(600) → expected 0
Test 2: delivery(700) → expected 0
Test 3: delivery(300) → expected 40 -
9.🧪 One test case fails. Which one?
📝 Rule: a quiz is passed with 5 or more right answers.
function result(right) {
if (right > 5) {
return "Pass";
}
return "Try again";
}
Test 1: result(5) → expected Pass
Test 2: result(7) → expected Pass
Test 3: result(2) → expected Try again (a) Test 1 (b) Test 3 (c) Test 2 -
10.🧪 What is the ACTUAL result of Test 1?
🎟️ Rule: a ticket costs 50 for children under 11, and 100 for everyone else.
function price(age) {
if (age < 11) {
return 50;
}
return 100;
}
Test 1: price(20) → expected 100
Test 2: price(17) → expected 100
Test 3: price(7) → expected 50 -
11.🧪 What is the ACTUAL result of Test 2?
🎟️ Rule: a ticket costs 50 for children under 12, and 100 for everyone else.
function price(age) {
if (age <= 12) {
return 50;
}
return 100;
}
Test 1: price(8) → expected 50
Test 2: price(19) → expected 100
Test 3: price(16) → expected 100 - 12.🧪 Values right at a limit, like age 12 for “under 12”, are called ___. (a) easy cases (b) phone cases (c) edge cases (d) old cases
-
13.🧪 How many of these test cases pass?
🎟️ Rule: a ticket costs 50 for children under 11, and 100 for everyone else.
function price(age) {
if (age <= 11) {
return 50;
}
return 100;
}
Test 1: price(8) → expected 50
Test 2: price(12) → expected 100
Test 3: price(13) → expected 100 - 14.🧪 What is the actual result of a test? (a) what we hope for (b) what the app really does (c) the test’s number (d) the app’s name
-
15.🧪 How many of these test cases pass?
🎟️ Rule: a ticket costs 50 for children under 10, and 100 for everyone else.
function price(age) {
if (age <= 10) {
return 50;
}
return 100;
}
Test 1: price(11) → expected 100
Test 2: price(14) → expected 100
Test 3: price(7) → expected 50 -
16.🧪 One test case fails. Which one?
🚚 Rule: delivery is free (0) when the order is 500 or more; otherwise it costs 40.
function delivery(total) {
if (total > 500) {
return 0;
}
return 40;
}
Test 1: delivery(500) → expected 0
Test 2: delivery(350) → expected 40
Test 3: delivery(650) → expected 0 (a) Test 1 (b) Test 3 (c) Test 2 -
17.🧪 One test case fails. Which one?
🎟️ Rule: a ticket costs 50 for children under 8, and 100 for everyone else.
function price(age) {
if (age <= 8) {
return 50;
}
return 100;
}
Test 1: price(8) → expected 100
Test 2: price(5) → expected 50
Test 3: price(11) → expected 100 (a) Test 2 (b) Test 1 (c) Test 3 -
18.🧪 One test case fails. Which one?
🎟️ Rule: a ticket costs 50 for children under 9, and 100 for everyone else.
function price(age) {
if (age <= 9) {
return 50;
}
return 100;
}
Test 1: price(8) → expected 50
Test 2: price(15) → expected 100
Test 3: price(9) → expected 100 (a) Test 1 (b) Test 3 (c) Test 2 -
19.🧪 How many of these test cases pass?
🎟️ Rule: a ticket costs 50 for children under 10, and 100 for everyone else.
function price(age) {
if (age < 10) {
return 50;
}
return 100;
}
Test 1: price(16) → expected 100
Test 2: price(8) → expected 50
Test 3: price(10) → expected 100 -
20.🧪 What is the ACTUAL result of Test 1?
🎟️ Rule: a ticket costs 50 for children under 12, and 100 for everyone else.
function price(age) {
if (age <= 12) {
return 50;
}
return 100;
}
Test 1: price(12) → expected 100
Test 2: price(17) → expected 100
Test 3: price(11) → expected 50 -
21.🧪 What is the ACTUAL result of Test 2?
🎟️ Rule: a ticket costs 50 for children under 8, and 100 for everyone else.
function price(age) {
if (age <= 8) {
return 50;
}
return 100;
}
Test 1: price(17) → expected 100
Test 2: price(14) → expected 100
Test 3: price(5) → expected 50 -
22.🧪 What is the ACTUAL result of Test 1?
🚚 Rule: delivery is free (0) when the order is 400 or more; otherwise it costs 40.
function delivery(total) {
if (total >= 400) {
return 0;
}
return 40;
}
Test 1: delivery(450) → expected 0
Test 2: delivery(200) → expected 40
Test 3: delivery(400) → expected 0 -
23.🧪 One test case fails. Which one?
🎟️ Rule: a ticket costs 50 for children under 11, and 100 for everyone else.
function price(age) {
if (age <= 11) {
return 50;
}
return 100;
}
Test 1: price(11) → expected 100
Test 2: price(16) → expected 100
Test 3: price(7) → expected 50 (a) Test 2 (b) Test 3 (c) Test 1 -
24.🧪 How many of these test cases pass?
🎟️ Rule: a ticket costs 50 for children under 13, and 100 for everyone else.
function price(age) {
if (age <= 13) {
return 50;
}
return 100;
}
Test 1: price(15) → expected 100
Test 2: price(13) → expected 100
Test 3: price(10) → expected 50 -
25.🧪 One test case fails. Which one?
🎟️ Rule: a ticket costs 50 for children under 11, and 100 for everyone else.
function price(age) {
if (age <= 11) {
return 50;
}
return 100;
}
Test 1: price(11) → expected 100
Test 2: price(14) → expected 100
Test 3: price(10) → expected 50 (a) Test 1 (b) Test 3 (c) Test 2 -
26.🧪 How many of these test cases pass?
📝 Rule: a quiz is passed with 5 or more right answers.
function result(right) {
if (right > 5) {
return "Pass";
}
return "Try again";
}
Test 1: result(7) → expected Pass
Test 2: result(2) → expected Try again
Test 3: result(5) → expected Pass -
27.🧪 What is the ACTUAL result of Test 1?
🎟️ Rule: a ticket costs 50 for children under 11, and 100 for everyone else.
function price(age) {
if (age < 11) {
return 50;
}
return 100;
}
Test 1: price(11) → expected 100
Test 2: price(17) → expected 100
Test 3: price(9) → expected 50 -
28.🧪 How many of these test cases pass?
🎟️ Rule: a ticket costs 50 for children under 14, and 100 for everyone else.
function price(age) {
if (age <= 14) {
return 50;
}
return 100;
}
Test 1: price(16) → expected 100
Test 2: price(11) → expected 50
Test 3: price(14) → expected 100 -
29.🧪 How many of these test cases pass?
🚚 Rule: delivery is free (0) when the order is 500 or more; otherwise it costs 40.
function delivery(total) {
if (total >= 500) {
return 0;
}
return 40;
}
Test 1: delivery(550) → expected 0
Test 2: delivery(600) → expected 0
Test 3: delivery(400) → expected 40 -
30.🧪 How many of these test cases pass?
📝 Rule: a quiz is passed with 8 or more right answers.
function result(right) {
if (right >= 8) {
return "Pass";
}
return "Try again";
}
Test 1: result(9) → expected Pass
Test 2: result(7) → expected Try again
Test 3: result(12) → expected Pass -
31.🧪 How many of these test cases pass?
🚚 Rule: delivery is free (0) when the order is 500 or more; otherwise it costs 40.
function delivery(total) {
if (total > 500) {
return 0;
}
return 40;
}
Test 1: delivery(450) → expected 40
Test 2: delivery(500) → expected 0
Test 3: delivery(550) → expected 0 -
32.🧪 What is the ACTUAL result of Test 2?
🎟️ Rule: a ticket costs 50 for children under 10, and 100 for everyone else.
function price(age) {
if (age < 10) {
return 50;
}
return 100;
}
Test 1: price(7) → expected 50
Test 2: price(12) → expected 100
Test 3: price(10) → expected 100 -
33.🧪 What is the ACTUAL result of Test 3?
🎟️ Rule: a ticket costs 50 for children under 9, and 100 for everyone else.
function price(age) {
if (age < 9) {
return 50;
}
return 100;
}
Test 1: price(15) → expected 100
Test 2: price(7) → expected 50
Test 3: price(18) → expected 100 -
34.🧪 How many of these test cases pass?
🎟️ Rule: a ticket costs 50 for children under 8, and 100 for everyone else.
function price(age) {
if (age < 8) {
return 50;
}
return 100;
}
Test 1: price(16) → expected 100
Test 2: price(5) → expected 50
Test 3: price(13) → expected 100 -
35.🧪 What is the ACTUAL result of Test 1?
🎟️ Rule: a ticket costs 50 for children under 8, and 100 for everyone else.
function price(age) {
if (age < 8) {
return 50;
}
return 100;
}
Test 1: price(9) → expected 100
Test 2: price(8) → expected 100
Test 3: price(7) → expected 50 -
36.🧪 One test case fails. Which one?
🎟️ Rule: a ticket costs 50 for children under 14, and 100 for everyone else.
function price(age) {
if (age <= 14) {
return 50;
}
return 100;
}
Test 1: price(11) → expected 50
Test 2: price(14) → expected 100
Test 3: price(17) → expected 100 (a) Test 2 (b) Test 1 (c) Test 3 -
37.🧪 One test case fails. Which one?
📝 Rule: a quiz is passed with 6 or more right answers.
function result(right) {
if (right > 6) {
return "Pass";
}
return "Try again";
}
Test 1: result(6) → expected Pass
Test 2: result(3) → expected Try again
Test 3: result(7) → expected Pass (a) Test 2 (b) Test 3 (c) Test 1 -
38.🧪 What is the ACTUAL result of Test 1?
🎟️ Rule: a ticket costs 50 for children under 9, and 100 for everyone else.
function price(age) {
if (age < 9) {
return 50;
}
return 100;
}
Test 1: price(9) → expected 100
Test 2: price(5) → expected 50
Test 3: price(11) → expected 100 -
39.🧪 What is the ACTUAL result of Test 2?
🎟️ Rule: a ticket costs 50 for children under 12, and 100 for everyone else.
function price(age) {
if (age < 12) {
return 50;
}
return 100;
}
Test 1: price(15) → expected 100
Test 2: price(16) → expected 100
Test 3: price(8) → expected 50 -
40.🧪 What is the ACTUAL result of Test 3?
🎟️ Rule: a ticket costs 50 for children under 14, and 100 for everyone else.
function price(age) {
if (age < 14) {
return 50;
}
return 100;
}
Test 1: price(15) → expected 100
Test 2: price(12) → expected 50
Test 3: price(18) → expected 100
Answer key
- 3
- 3
- actual is not expected
- real users
- Test 3
- Test 1
- Test 1
- 3
- Test 1
- 100
- 100
- edge cases
- 3
- what the app really does
- 3
- Test 1
- Test 1
- Test 3
- 3
- 50
- 100
- 0
- Test 1
- 2
- Test 1
- 2
- 100
- 2
- 3
- 3
- 2
- 100
- 100
- 3
- 100
- Test 2
- Test 1
- 100
- 100
- 100
Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students