← Testing: expected vs actual lesson New set →

App Dev Worksheet: Testing

App development lesson 22: Testing: expected vs actual · Set 7 · 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.🧪 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(9) → expected Pass
    Test 3: result(4) → expected Try again
    (a) Test 2 (b) Test 3 (c) Test 1
  2. 2.🧪 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(11) → expected 50
    Test 2: price(19) → expected 100
    Test 3: price(22) → expected 100
  3. 3.🧪 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(10) → expected Pass
    Test 2: result(8) → expected Pass
    Test 3: result(7) → expected Try again
    (a) Test 2 (b) Test 3 (c) Test 1
  4. 4.🧪 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(10) → expected 100
    Test 2: price(7) → expected 50
    Test 3: price(16) → expected 100
    (a) Test 1 (b) Test 3 (c) Test 2
  5. 5.🧪 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(250) → expected 40
    Test 2: delivery(300) → expected 0
    Test 3: delivery(450) → expected 0
  6. 6.🧪 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(14) → expected 100
    Test 2: price(10) → expected 100
    Test 3: price(6) → expected 50
  7. 7.🧪 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(5) → expected 50
    Test 3: price(12) → expected 100
  8. 8.🧪 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(2) → expected Try again
    Test 2: result(7) → expected Pass
    Test 3: result(5) → expected Pass
    (a) Test 2 (b) Test 3 (c) Test 1
  9. 9.🧪 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(300) → expected 40
    Test 2: delivery(400) → expected 0
    Test 3: delivery(550) → expected 0
    (a) Test 2 (b) Test 1 (c) Test 3
  10. 10.🧪 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(2) → expected Try again
    Test 2: result(5) → expected Pass
    Test 3: result(6) → expected Pass
    (a) Test 2 (b) Test 3 (c) Test 1
  11. 11.🧪 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(14) → expected 100
    Test 2: price(12) → expected 50
    Test 3: price(17) → expected 100
    (a) Test 2 (b) Test 3 (c) Test 1
  12. 12.🧪 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(450) → expected 40
    Test 2: delivery(500) → expected 0
    Test 3: delivery(700) → expected 0
    (a) Test 3 (b) Test 1 (c) Test 2
  13. 13.🧪 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(12) → expected 50
    Test 3: price(17) → expected 100
    (a) Test 1 (b) Test 3 (c) Test 2
  14. 14.🧪 Who else should try an app before release? (a) only the coder (b) nobody (c) real users (d) the app icon
  15. 15.🧪 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(900) → expected 0
    Test 2: delivery(1000) → expected 0
    Test 3: delivery(700) → expected 40
  16. 16.🧪 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(20) → expected 100
    Test 2: price(14) → expected 100
    Test 3: price(10) → expected 50
  17. 17.🧪 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(13) → expected Pass
    Test 2: result(10) → expected Pass
    Test 3: result(7) → expected Try again
  18. 18.🧪 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(750) → expected 40
    Test 2: delivery(1000) → expected 0
    Test 3: delivery(1050) → expected 0
  19. 19.🧪 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(10) → expected 100
    Test 3: price(5) → expected 50
    (a) Test 2 (b) Test 1 (c) Test 3
  20. 20.🧪 What is the actual result of a test? (a) the app’s name (b) what we hope for (c) what the app really does (d) the test’s number
  21. 21.🧪 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(350) → expected 40
    Test 2: delivery(550) → expected 0
    Test 3: delivery(500) → expected 0
  22. 22.🧪 A test fails when ___. (a) the font is big (b) the app is new (c) both are the same (d) actual is not expected
  23. 23.🧪 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(11) → expected 100
    Test 2: price(9) → expected 50
    Test 3: price(10) → expected 100
    (a) Test 2 (b) Test 3 (c) Test 1
  24. 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(13) → expected 100
    Test 2: price(11) → expected 50
    Test 3: price(19) → expected 100
  25. 25.🧪 What is the ACTUAL result of Test 3?
    🚚 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(400) → expected 0
    Test 3: delivery(600) → expected 0
  26. 26.🧪 How many of these test cases pass?
    🚚 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(600) → expected 40
    Test 2: delivery(950) → expected 0
    Test 3: delivery(800) → expected 0
  27. 27.🧪 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(9) → expected 50
    (a) Test 2 (b) Test 1 (c) Test 3
  28. 28.🧪 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(11) → expected 50
    Test 2: price(16) → expected 100
    Test 3: price(17) → expected 100
  29. 29.🧪 What is the ACTUAL result of Test 3?
    🚚 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(400) → expected 40
    Test 2: delivery(650) → expected 0
    Test 3: delivery(700) → expected 0
  30. 30.🧪 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(15) → expected 100
    Test 2: price(8) → expected 50
    Test 3: price(11) → expected 100
  31. 31.🧪 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(12) → expected 100
    Test 2: price(10) → expected 50
    Test 3: price(18) → expected 100
  32. 32.🧪 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(400) → expected 0
    Test 2: delivery(150) → expected 40
    Test 3: delivery(300) → expected 0
    (a) Test 1 (b) Test 2 (c) Test 3
  33. 33.🧪 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(4) → expected 50
    Test 2: price(11) → expected 100
    Test 3: price(13) → expected 100
  34. 34.🧪 What is the ACTUAL result of Test 1?
    🚚 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(400) → expected 0
    Test 3: delivery(350) → expected 0
  35. 35.🧪 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(8) → expected 50
    Test 2: price(12) → expected 100
    Test 3: price(17) → expected 100
    (a) Test 1 (b) Test 3 (c) Test 2
  36. 36.🧪 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(6) → expected 50
    Test 3: price(10) → expected 100
  37. 37.🧪 What is the ACTUAL result of Test 3?
    🎟️ 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(7) → expected 50
  38. 38.🧪 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(6) → expected 50
    Test 2: price(16) → expected 100
    Test 3: price(10) → expected 100
  39. 39.🧪 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(3) → expected Try again
    Test 3: result(6) → expected Pass
  40. 40.🧪 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(7) → expected Pass
    Test 2: result(4) → expected Try again
    Test 3: result(9) → expected Pass

Answer key

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

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