App development · lesson 22 of 24 · free

Testing: expected vs actual — App development for students

Testing checks that an app follows its rules. A test case is an input together with its expected result, worked out from the rule. Run the code with the input to get the actual result: if actual equals expected, the test passes; if not, it fails and there is a bug. Bugs love edge cases — values right at a limit, like age 12 for “under 12” — so good testers always include the limit itself.

▶ Watch how it works

Got it? Practise ↓

Developer's tip

Expected vs actual — “run each test case and compare what happens with what should happen”

  1. Test case = input + expected result (from the rule).
  2. Run the code: actual = expected → pass; otherwise → fail.
  3. Always test the edge value: < and <= differ only there.

Use it for: Checking your app before release and writing good test cases for school projects.

Worked example: 🧪 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(750) → expected 0
Test 2: delivery(450) → expected 40
Test 3: delivery(500) → expected 0 → Test 3

  1. The rule says 500 or more (>=); the code tests > 500.
  2. For 500 the code returns 40, but 0 is expected — Test 3 fails.

Check: Tests 1 and 2 pass; changing > to >= fixes Test 3 ✓

▶ Watch it animated

✏️ Practice

Work it out in your head or on paper, type the answer and press Check. Stuck? Press “Show me how”.

Right: 0 · Tried: 0

🏁 Lesson 22 test

20 questions. Check each answer, then go to the next one. Get 16 or more right to pass.

🏅 Sign in with Google to earn the 🧪 Test Case Tester badge when you pass — and a certificate when you finish all 8 lessons of Part 3 · Logic and Building. You can still take the test without signing in.

🖨️ App Dev Worksheet: Testing

✨ Free AI tutor

Ask the AI tutor about this lesson

Why does it work? When should you use it? Ask in English, मराठी or हिंदी.

Sign in with Google to ask Free — 20 questions a day.

👩‍🏫 App development classes near you — online or at home

Prefer a real teacher? TalentJR teachers take live online classes anywhere in India and visit homes in selected cities. Tell us what you need and our team will call you with timings and fees.

Live online classesSmall groups or 1:1 with a teacher, from home, any city.
Teacher at homeA TalentJR teacher visits your home (selected cities).
At a centreClasses at a TalentJR partner centre near you, where available.
Badges, certificates & gifts A badge for every lesson you pass, a certificate for every part you finish, plus TalentJR Points for daily practice. HTML, CSS & web development Build web pages with HTML, CSS and a little JavaScript.