3.2.11 - Test data and program refinement (Python)

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–10Category and purposeExpected outcome
5Normal: typical valid bookingAccept
0Boundary below minimum; also erroneousReject
1Boundary at minimumAccept
10Boundary at maximumAccept
11Boundary above maximum; also erroneousReject
30Erroneous: clearly above maximumReject

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