Testing programs — Computing, 11–13
Testing means deliberately trying a program with chosen examples to discover whether it behaves as intended. It gives you evidence before other people rely on your code.
What testing is
A test is a question you ask a program: “When I give you this, do you produce that?” You choose inputs whose answers you know, run the code, and compare what happened with what should have happened. A test does not prove that every case is correct, but it can reveal important failures.
Why test programs?
A program can look fine when you try one easy example and still fail for an empty answer, a very large number, or an unexpected action. Testing comes from the need to trust software without checking every line by hand each time. It turns a vague hope into a check you can repeat.
A boundary test
Imagine a program that says whether someone may enter a ride when the minimum height is 140 cm. First, test 150: it should say yes. Next, test 130: it should say no. Finally, test 140 exactly; this boundary case exposes whether the code uses “at least” or accidentally requires more than 140.
The easy-example trap
A common mistake is testing only the example shown in class, because it feels like a representative proof. It is reasonable: that example is familiar and the correct answer is already visible. But software often breaks at edges, empty inputs, or unusual combinations, so vary the data instead of changing only the numbers that look convenient.
Where tests matter
Tests are used in games, websites, banking apps, and devices such as traffic lights. Before an update is released, earlier tests can be run again to check that a new feature did not break an old one. You can use the same habit in a small project: test after each meaningful change.
Keep exploring
Other languages
Loading MyLeoNes™…