← Testing: expected vs actual lesson New set →

App Dev Worksheet: Testing

App development lesson 22: Testing: expected vs actual · Set 123 · 40 questions
TalentJR

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. 1.🧪 How many of these test cases pass?
    🚚 Rule: delivery is free (0) when the order is 300 or more; otherwise it costs 40.
    function delivery(total) {
      if (total >= 300) {
        return 0;
      }
      return 40;
    }
    Test 1: delivery(650) → expected 0
    Test 2: delivery(250) → expected 40
    Test 3: delivery(600) → expected 0
  2. 2.🧪 How many of these test cases pass?
    🎟️ 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(11) → expected 50
    Test 3: price(14) → expected 100
  3. 3.🧪 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(15) → expected 100
    Test 2: price(6) → expected 50
    Test 3: price(14) → expected 100
  4. 4.🧪 Values right at a limit, like age 12 for “under 12”, are called ___. (a) phone cases (b) old cases (c) edge cases (d) easy cases
  5. 5.🧪 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(12) → expected 100
    Test 2: price(9) → expected 100
    Test 3: price(7) → expected 50
  6. 6.🧪 One test case fails. Which one?
    🚚 Rule: delivery is free (0) when the order is 300 or more; otherwise it costs 40.
    function delivery(total) {
      if (total > 300) {
        return 0;
      }
      return 40;
    }
    Test 1: delivery(150) → expected 40
    Test 2: delivery(600) → expected 0
    Test 3: delivery(300) → expected 0
    (a) Test 1 (b) Test 3 (c) Test 2
  7. 7.🧪 How many of these test cases pass?
    🚚 Rule: delivery is free (0) when the order is 800 or more; otherwise it costs 40.
    function delivery(total) {
      if (total >= 800) {
        return 0;
      }
      return 40;
    }
    Test 1: delivery(800) → expected 0
    Test 2: delivery(600) → expected 40
    Test 3: delivery(1050) → expected 0
  8. 8.🧪 What is the ACTUAL result of Test 2?
    🚚 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(200) → expected 40
    Test 2: delivery(550) → expected 0
    Test 3: delivery(400) → expected 0
  9. 9.🧪 How many of these test cases pass?
    🎟️ 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(11) → expected 100
    Test 3: price(7) → expected 50
  10. 10.🧪 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(5) → expected 50
    (a) Test 3 (b) Test 1 (c) Test 2
  11. 11.🧪 A test fails when ___. (a) the app is new (b) the font is big (c) both are the same (d) actual is not expected
  12. 12.🧪 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(4) → expected Try again
    Test 2: result(6) → expected Pass
    Test 3: result(5) → expected Pass
  13. 13.🧪 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(17) → expected 100
    Test 3: price(8) → expected 50
    (a) Test 2 (b) Test 1 (c) Test 3
  14. 14.🧪 Who else should try an app before release? (a) the app icon (b) nobody (c) only the coder (d) real users
  15. 15.🧪 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(6) → expected Pass
    Test 2: result(8) → expected Pass
    Test 3: result(5) → expected Try again
  16. 16.🧪 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(5) → expected 50
    Test 2: price(9) → expected 100
    Test 3: price(8) → expected 100
  17. 17.🧪 A test case is an input together with its ___. (a) expected result (b) app icon (c) font size (d) screen colour
  18. 18.🧪 What is the actual result of a test? (a) the test’s number (b) the app’s name (c) what we hope for (d) what the app really does
  19. 19.🧪 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(5) → expected Pass
    Test 2: result(6) → expected Pass
    Test 3: result(2) → expected Try again
  20. 20.🧪 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(11) → expected 100
    Test 2: price(8) → expected 100
    Test 3: price(5) → expected 50
    (a) Test 1 (b) Test 3 (c) Test 2
  21. 21.🧪 What is the ACTUAL result of Test 2?
    🎟️ 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(12) → expected 50
    Test 3: price(18) → expected 100
  22. 22.🧪 What is the ACTUAL result of Test 2?
    🎟️ 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(13) → expected 100
    Test 2: price(15) → expected 100
    Test 3: price(12) → expected 50
  23. 23.🧪 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(18) → expected 100
    Test 2: price(17) → expected 100
    Test 3: price(12) → expected 50
  24. 24.🧪 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(10) → expected 100
    Test 2: price(7) → expected 50
    Test 3: price(9) → expected 100
  25. 25.🧪 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(10) → expected 100
    Test 2: price(11) → expected 100
    Test 3: price(9) → expected 50
  26. 26.🧪 What is the ACTUAL result of Test 1?
    🎟️ 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(14) → expected 100
    Test 2: price(16) → expected 100
    Test 3: price(9) → expected 50
  27. 27.🧪 How many of these test cases pass?
    🚚 Rule: delivery is free (0) when the order is 600 or more; otherwise it costs 40.
    function delivery(total) {
      if (total > 600) {
        return 0;
      }
      return 40;
    }
    Test 1: delivery(900) → expected 0
    Test 2: delivery(400) → expected 40
    Test 3: delivery(1000) → expected 0
  28. 28.🧪 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(14) → expected 100
    Test 2: price(13) → expected 100
    Test 3: price(5) → expected 50
  29. 29.🧪 One test case fails. Which one?
    🚚 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(600) → expected 0
    Test 2: delivery(300) → expected 40
    Test 3: delivery(400) → expected 0
    (a) Test 3 (b) Test 1 (c) Test 2
  30. 30.🧪 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(18) → expected 100
    Test 2: price(21) → expected 100
    Test 3: price(8) → expected 50
  31. 31.🧪 What is the ACTUAL result of Test 2?
    🚚 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(750) → expected 0
    Test 2: delivery(200) → expected 40
    Test 3: delivery(700) → expected 0
  32. 32.🧪 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(350) → expected 40
    Test 2: delivery(850) → expected 0
    Test 3: delivery(700) → expected 0
  33. 33.🧪 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(13) → expected 100
    Test 3: price(8) → expected 50
    (a) Test 1 (b) Test 2 (c) Test 3
  34. 34.🧪 How many of these test cases pass?
    📝 Rule: a quiz is passed with 7 or more right answers.
    function result(right) {
      if (right >= 7) {
        return "Pass";
      }
      return "Try again";
    }
    Test 1: result(9) → expected Pass
    Test 2: result(8) → expected Pass
    Test 3: result(5) → expected Try again
  35. 35.🧪 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(17) → expected 100
    Test 2: price(14) → expected 100
    Test 3: price(7) → expected 50
  36. 36.🧪 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(10) → expected 100
    Test 2: price(9) → expected 50
    Test 3: price(13) → expected 100
  37. 37.🧪 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(7) → expected 50
    Test 2: price(9) → expected 100
    Test 3: price(11) → expected 100
    (a) Test 1 (b) Test 2 (c) Test 3
  38. 38.🧪 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(8) → expected 100
    Test 2: price(9) → expected 100
    Test 3: price(4) → expected 50
  39. 39.🧪 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(5) → expected Try again
    Test 2: result(7) → expected Pass
    Test 3: result(6) → expected Pass
    (a) Test 3 (b) Test 2 (c) Test 1
  40. 40.🧪 One test case fails. Which one?
    🚚 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(550) → expected 0
    Test 2: delivery(350) → expected 40
    Test 3: delivery(400) → expected 0
    (a) Test 3 (b) Test 1 (c) Test 2

Answer key

  1. 3
  2. 2
  3. 100
  4. edge cases
  5. 3
  6. Test 3
  7. 3
  8. 0
  9. 2
  10. Test 1
  11. actual is not expected
  12. 2
  13. Test 1
  14. real users
  15. 3
  16. 100
  17. expected result
  18. what the app really does
  19. 2
  20. Test 2
  21. 50
  22. 100
  23. 3
  24. 50
  25. 2
  26. 100
  27. 3
  28. 100
  29. Test 3
  30. 100
  31. 40
  32. 3
  33. Test 1
  34. 3
  35. 3
  36. 3
  37. Test 2
  38. 50
  39. Test 3
  40. Test 3

Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students