Testing lab – test data, error types and data validation
Computer ScienceAlgorithms & Problem SolvingAges 13–14
Loading…
Sign in to playThree hands-on activities about testing programs. Design normal, boundary, extreme and erroneous test data for a mark-to-grade function with four hidden bugs, run each test, fix the bugs and test again. Tell syntax, run-time and logic errors apart in six Python programs, using a trace table to find the faulty line. Validate data entry with presence, length, type, range, format, lookup and ISBN check-digit checks, and compare validation with verification by double entry and visual check.
Lesson: Testing, debugging and data validation
What it shows
Programs are tested with planned data: normal values, boundary values on each side of a limit, extreme values at the ends of the valid range and erroneous data that must be rejected. A syntax error stops the code being translated, a run-time error crashes the program while it runs, and a logic error gives a wrong answer with no message, so it is found only by comparing output with the expected result. Validation checks that input is sensible; verification checks that it matches the source.
How to use
In Test data, type a value, choose its type and the expected result, then press Add and run; when a test exposes a bug, press Fix, then Re-run all tests and finally Final test. In Error types, choose a Program, press Run or Step, classify the error and try a line from the fix list with Apply and test. In Validation, fill the form or pick an Example, press Validate and save, then Import batch and Visual check.
Parameters you can change
- Screen Test data, Error types and trace table, Data validation
- Program with an error (Error types screen) Average – missing colon, Count passes – missing bracket, Average – division by zero, Highest mark – index out of range, Sum 1 to n – one loop short, Mean of three – wrong order of operations
Questions to explore
- Why should you test both 79 and 80 instead of just a typical mark such as 85?
- Is dividing by zero a run-time error or a logic error, and why does it happen only with some data?
- If a record passes every validation check, can you be sure that the data is correct?