← Testing: expected vs actual lesson New set →

App Dev Worksheet: Testing

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

Answer key

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

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