← Testing: expected vs actual lesson New set →

App Dev Worksheet: Testing

App development lesson 22: Testing: expected vs actual · Set 67 · 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.🧪 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
  2. 2.🧪 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(14) → expected 100
    Test 2: price(12) → expected 100
    Test 3: price(6) → expected 50
  3. 3.🧪 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(9) → expected 100
    Test 3: price(7) → expected 50
    (a) Test 1 (b) Test 3 (c) Test 2
  4. 4.🧪 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(13) → expected 100
    Test 2: price(5) → expected 50
    Test 3: price(12) → expected 100
  5. 5.🧪 Who else should try an app before release? (a) only the coder (b) real users (c) nobody (d) the app icon
  6. 6.🧪 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(13) → expected 100
    Test 2: price(10) → expected 50
    Test 3: price(15) → expected 100
  7. 7.🧪 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(11) → expected 50
    Test 2: price(17) → expected 100
    Test 3: price(18) → expected 100
  8. 8.🧪 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(12) → expected 100
    Test 3: price(5) → expected 50
  9. 9.🧪 What is the actual result of a test? (a) the app’s name (b) what the app really does (c) the test’s number (d) what we hope for
  10. 10.🧪 What is the ACTUAL result of Test 3?
    🚚 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(800) → expected 0
    Test 2: delivery(550) → expected 40
    Test 3: delivery(750) → expected 0
  11. 11.🧪 What is the ACTUAL result of Test 2?
    🚚 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(700) → expected 0
    Test 2: delivery(750) → expected 0
    Test 3: delivery(550) → expected 40
  12. 12.🧪 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(350) → expected 0
    Test 2: delivery(250) → expected 40
    Test 3: delivery(450) → expected 0
  13. 13.🧪 One test case fails. Which one?
    📝 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(5) → expected Try again
    Test 2: result(7) → expected Pass
    Test 3: result(9) → expected Pass
    (a) Test 3 (b) Test 1 (c) Test 2
  14. 14.🧪 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(10) → expected 100
    Test 2: price(8) → expected 50
    Test 3: price(12) → expected 100
  15. 15.🧪 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(8) → expected Pass
    Test 2: result(10) → expected Pass
    Test 3: result(5) → expected Try again
  16. 16.🧪 One test case fails. Which one?
    📝 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(4) → expected Try again
    Test 2: result(9) → expected Pass
    Test 3: result(7) → expected Pass
    (a) Test 2 (b) Test 3 (c) Test 1
  17. 17.🧪 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(16) → expected 100
    Test 2: price(14) → expected 100
    Test 3: price(8) → expected 50
  18. 18.🧪 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(12) → expected Pass
    Test 2: result(9) → expected Pass
    Test 3: result(6) → expected Try again
  19. 19.🧪 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(700) → expected 0
    Test 2: delivery(400) → expected 40
    Test 3: delivery(800) → expected 0
  20. 20.🧪 What is the ACTUAL result of Test 3?
    🎟️ 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(16) → expected 100
    Test 3: price(11) → expected 50
  21. 21.🧪 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(14) → expected 100
    Test 2: price(8) → expected 50
    Test 3: price(9) → expected 100
  22. 22.🧪 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(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 10, and 100 for everyone else.
    function price(age) {
      if (age < 10) {
        return 50;
      }
      return 100;
    }
    Test 1: price(8) → expected 50
    Test 2: price(12) → expected 100
    Test 3: price(10) → expected 100
  24. 24.🧪 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(18) → expected 100
    Test 2: price(15) → expected 100
    Test 3: price(11) → expected 50
  25. 25.🧪 What is the ACTUAL result of Test 1?
    🚚 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(800) → expected 0
    Test 2: delivery(400) → expected 40
    Test 3: delivery(650) → expected 0
  26. 26.🧪 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(5) → expected Try again
    Test 2: result(9) → expected Pass
    Test 3: result(8) → expected Pass
    (a) Test 1 (b) Test 2 (c) Test 3
  27. 27.🧪 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(19) → expected 100
    Test 2: price(9) → expected 50
    Test 3: price(16) → expected 100
  28. 28.🧪 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(8) → expected 100
    Test 2: price(6) → expected 50
    Test 3: price(12) → expected 100
  29. 29.🧪 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(7) → expected Pass
    Test 3: result(5) → expected Try again
    (a) Test 2 (b) Test 1 (c) Test 3
  30. 30.🧪 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(8) → expected Pass
    Test 2: result(10) → expected Pass
    Test 3: result(6) → expected Try again
    (a) Test 3 (b) Test 1 (c) Test 2
  31. 31.🧪 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(15) → expected 100
    Test 2: price(17) → expected 100
    Test 3: price(11) → expected 50
  32. 32.🧪 What is the ACTUAL result of Test 2?
    🚚 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(700) → expected 0
    Test 2: delivery(500) → expected 40
    Test 3: delivery(650) → expected 0
  33. 33.🧪 What is the ACTUAL result of Test 3?
    🎟️ 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(12) → expected 100
    Test 2: price(13) → expected 100
    Test 3: price(8) → expected 50
  34. 34.🧪 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(17) → expected 100
    Test 2: price(11) → expected 100
    Test 3: price(7) → expected 50
  35. 35.🧪 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(9) → expected 100
    Test 2: price(8) → expected 100
    Test 3: price(5) → expected 50
    (a) Test 2 (b) Test 3 (c) Test 1
  36. 36.🧪 One test case fails. Which one?
    📝 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(6) → expected Try again
    Test 2: result(8) → expected Pass
    Test 3: result(7) → expected Pass
    (a) Test 1 (b) Test 3 (c) Test 2
  37. 37.🧪 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(4) → expected Try again
    (a) Test 2 (b) Test 3 (c) Test 1
  38. 38.🧪 One test case fails. Which one?
    🎟️ 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(17) → expected 100
    Test 2: price(12) → expected 100
    Test 3: price(10) → expected 50
    (a) Test 1 (b) Test 2 (c) Test 3
  39. 39.🧪 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(5) → expected 50
    Test 2: price(11) → expected 100
    Test 3: price(12) → expected 100
  40. 40.🧪 What is the ACTUAL result of Test 1?
    🚚 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(700) → expected 40
    Test 2: delivery(1200) → expected 0
    Test 3: delivery(1100) → expected 0

Answer key

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

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