3.2.11 - Test data and program refinement (Python)
Testing compares a program's actual behaviour with the behaviour its requirements demand. You will choose and justify representative inputs, use a test table and refine a Python routine when a result reveals a fault.
Testing against expected behavior
A useful test has a purpose, concrete input and an expected outcome decided from the requirements before execution.
Test data
Inputs chosen to check how an algorithm or program behaves, including values designed to reveal faults.
For a booking quantity permitted from 1 to 10 inclusive, an input 5 should be accepted. Record the actual result and compare it with that expected result. The expected result comes from the rule, not from assuming whatever the current program displays is correct.
A test table records input, category or reason, expected result, actual result and whether the test passed. Passing several tests provides evidence for those cases; it does not prove every possible execution is correct. Test the important branches and limits deliberately. Practical work should include designing, writing, testing and refining programs. NovaLearn practice supports those opportunities; it is not an assessed NEA and does not certify a centre's required practical programming statement.
Normal, boundary and erroneous data
Different categories check different risks, so one ordinary value is insufficient for a range rule.
Normal data is a typical valid value. Boundary data checks the limits and their immediate neighbours. Erroneous data is invalid data that should be handled appropriately, such as a quantity outside the permitted interval.
| Input for range 1–10 | Category and purpose | Expected outcome |
|---|---|---|
| 5 | Normal: typical valid booking | Accept |
| 0 | Boundary below minimum; also erroneous | Reject |
| 1 | Boundary at minimum | Accept |
| 10 | Boundary at maximum | Accept |
| 11 | Boundary above maximum; also erroneous | Reject |
| 30 | Erroneous: clearly above maximum | Reject |
AQA's boundary examples include 0, 1, 10, 11, on both sides of both limits. Categories can overlap: 0 is both a boundary test and an invalid input. State the intended purpose rather than arguing that a value can have only one label. Exam numeric input errors can be assumed not to involve an incorrect data type; out-of-range numbers still provide erroneous cases.
Continue this lesson.
You’re previewing NovaLearn without an account. Create a free account to read the rest.
Create free account