Computer Science
Grade 9
20 min
Testing Strategies
Testing Strategies
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Define software testing and explain its importance in the development process.
Differentiate between manual and automated testing.
Identify and describe three common types of test cases: normal, boundary, and edge cases.
Write simple test cases for a given function, including inputs and expected outputs.
Explain the concept of a 'bug' and its role in programming.
Use print statements to trace program execution and find simple errors.
Ever played a video game that crashed right before you beat the final boss? 💥 Let's learn how programmers work to prevent that from happening!
Writing code is only half the battle; making sure it works correctly is the other half! In this lesson, you'll learn how to think like a detective to find and fix...
2
Key Concepts & Vocabulary
TermDefinitionExample
BugAn error, flaw, or fault in a computer program that causes it to produce an incorrect or unexpected result, or to behave in unintended ways.A calculator app that shows '2 + 2 = 5' has a bug.
Software TestingThe process of evaluating and verifying that a software program does what it is supposed to do.Intentionally entering the wrong password on a website to make sure it correctly shows an 'Invalid Password' message.
Test CaseA specific set of inputs, conditions, and an expected result, developed for a particular objective, such as to exercise a particular program path or to verify compliance with a specific requirement.For a login function: Input username 'testuser', password 'pass123'. Expected Result: 'Login Successfu...
3
Core Syntax & Patterns
The Test Case Trio
Test with: 1. Normal Cases, 2. Boundary Cases, and 3. Edge Cases.
To be confident your code works, you must test more than just the obvious inputs. This trio helps you find hidden bugs by testing expected inputs (normal), inputs at the limits (boundary), and unexpected inputs (edge).
The 'Arrange, Act, Assert' (AAA) Pattern
1. Arrange: Set up the inputs and conditions. 2. Act: Run the code you want to test. 3. Assert: Check if the result is what you expected.
This is a simple, structured way to write any test case. It keeps your tests organized, clear, and easy for others to understand.
Debugging with Print Statements
Place `print()` statements at key points in your code to display the values of variables or confirm which code blocks are ru...
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
You are debugging a function with `print()` statements. You see the output from a print statement at the beginning of the function, but not from one just before the `return` statement. What is the most logical conclusion?
A.The function returned a value before the second print statement was reached.
B.The computer's monitor is broken.
C.The program crashed due to an error between the two print statements.
D.Either A or C could be true.
Challenging
You are creating a full test plan for a function `set_volume(level)` where `level` must be an integer from 0 to 100. Which set of test cases best represents a complete application of the 'Test Case Trio' (Normal, Boundary, Edge)?
A.Inputs: 50, 99. (Testing only normal cases)
B.Inputs: 0, 100. (Testing only boundary cases)
C.Inputs: -1, 101. (Testing only edge cases)
D.Inputs: 50, 0, 100, -1, 101. (Testing all three types)
Challenging
Why is the 'Arrange, Act, Assert' (AAA) pattern considered more effective for writing tests than just running code and visually checking the output?
A.Because it forces the test to be automated and repeatable, clearly separating setup, execution, and verification.
B.Because it makes the test code run significantly faster than other methods.
C.Because it only works for mathematical functions and is not useful for other code.
D.Because it automatically generates the test cases for you without any effort.
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free