Computer Science
Grade 5
20 min
Testing Systematically
Testing Systematically
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Define what a test case is and why it's important.
Identify and create test cases for 'happy paths', 'sad paths', and 'edge cases'.
Create a simple test plan in a table format with inputs, expected outcomes, and actual outcomes.
Systematically test a program with complex conditionals (if/else if/else).
Systematically test a program that uses a loop with a variable.
Explain what a 'bug' is and how systematic testing helps find them.
Analyze test results to determine if a program is working correctly.
Ever played a video game and found a weird glitch that let you walk through a wall? 🎮 How do you think we can find those glitches on purpose before the game is released?
In this lesson, you will learn how to bec...
2
Key Concepts & Vocabulary
TermDefinitionExample
Test CaseA single test you perform on your code with a specific input to check for a specific, expected result.For a program that adds two numbers, a test case would be: Input `5` and `3`. The expected result is `8`.
BugAn error or mistake in the code that causes the program to do something unexpected or incorrect.If your calculator program shows `2 + 2 = 5`, that's a bug!
Expected OutcomeWhat you believe the program *should* do when you run a test case.When testing a password checker, if the password is correct, the expected outcome is 'Access Granted'.
Actual OutcomeWhat the program *actually* does when you run a test case.You test your password checker with the correct password, but the actual outcome is 'Access Denied'. This means you fou...
3
Core Syntax & Patterns
The Test Plan Table
Create a table with columns: 'Test Case ID', 'Input(s)', 'Expected Outcome', 'Actual Outcome', 'Pass/Fail'.
Use this table before you run your code to plan your tests. It keeps you organized and makes it easy to see which tests found bugs.
Boundary Value Testing
For any condition that uses a range (e.g., `if score > 100`), always test three values: the number right before the boundary, the number on the boundary, and the number right after the boundary.
This rule helps you find 'off-by-one' errors. For `score > 100`, you would test `99`, `100`, and `101` to make sure the condition works perfectly.
4 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Challenging
A game's score is stored in an 8-bit binary number, which can hold a maximum value of 255. The score starts at 1 and doubles every time you collect a gem. After how many gems will the score 'overflow' and break?
A.6 gems (score = 64)
B.7 gems (score = 128)
C.8 gems (score = 256)
D.9 gems (score = 512)
Challenging
To get a 'Gold Badge', a player needs `(score > 1000 AND level > 5) OR time_played > 100` hours. Which player profile would be the most complex and important to test this rule?
A.score=2000, level=10, time_played=200 (all conditions are true)
B.score=1001, level=6, time_played=99 (the 'AND' part is barely true, the 'OR' part is false)
C.score=500, level=3, time_played=50 (all conditions are false)
D.score=500, level=10, time_played=101 (the 'AND' part is false, the 'OR' part is barely true)
Challenging
You only have time to run three tests on a new program that calculates shipping costs. Which testing strategy is best?
A.Test three different common orders to make sure it works for most people.
B.Test one very small order, one medium order, and one very large order.
C.Test an order with zero items, an order with a negative number of items, and an order with one item.
D.Test an order with one item, an order with the maximum allowed items, and an order with zero items.
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free