Loading…
Loading…
Loading…
OCR GCSE Computer Science · J277
OCR J277 Check the specification (PDF) (opens in a new tab)
A program can start successfully and display an answer, yet still give the wrong answer. It might also work with one input but crash when a user enters something unexpected. checks a program’s behaviour against what it should do, helping developers find errors and judge whether it works as intended.
The expected behaviour comes from the program’s requirements: the features and results that users need. Testing therefore asks both “Does it work correctly?” and “Does it do what the user asked for?”
To test meaningfully, a developer needs to know the expected result before running the test. They then run the program with chosen inputs and compare its actual behaviour with that expectation. A difference reveals a problem that needs investigating and correcting.
For example, a program intended to add two numbers should produce 7 when given 3 and 4. If it displays -1, it has run, but its result is incorrect. Testing exposes the fault; the developer must then correct the code and test it again to check the correction.
This supports correctness: producing the intended results. Testing different inputs also helps assess reliability: whether the program consistently works as intended, rather than succeeding only in a particular case.
Users do not always enter what a programmer expects. They may misunderstand an instruction, leave a field blank or type text where a number is needed. A robust program handles these situations without crashing or producing inappropriate results.
Consider a program that asks for a whole number from 1 to 10. It should accept 5, but reject "abc" safely, perhaps displaying a clear message and allowing another attempt. Testing should check both behaviours. Rejecting unsuitable input is a correct response, not a failure of the program.
Testing can also check security-related requirements. For example, a login system should refuse access when the password is incorrect. A successful login with the correct password alone does not show that this protection works.
Effective testing deliberately looks for situations in which the program might fail. This is sometimes called destructive testing: the aim is to uncover faults, not physically damage the computer or its data.
Choosing only inputs that already work can hide problems. A wider range of tests helps reveal incorrect outputs, crashes and unmet requirements so that developers can address them before users encounter them.
Testing increases confidence in a program, but passing the tests does not prove that every possible error has been removed.
Get unlimited access to all revision notes, key terms, and exam tips.
Testing should actively seek faults, not merely demonstrate successful cases. Passing tests increases confidence; it does not guarantee that a program is error-free.
Get unlimited access to all revision notes, key terms, and exam tips.
Give distinct reasons for testing: finding errors, checking that outputs are correct, checking user requirements and checking that unexpected input does not cause a crash.
Link your explanation to the program in the question rather than simply saying that testing 'makes it better'.
A program running without crashing does not necessarily mean that its output is correct.
Testing
The process of checking a program’s behaviour against expected results to find errors and assess whether it meets its requirements.
Correctness
A program’s ability to produce the intended results for valid inputs.
Reliability
A program’s ability to work consistently as intended without failing.
Robustness
A program’s ability to handle unexpected or invalid inputs without crashing or behaving incorrectly.
User requirement
A feature or behaviour that a program must provide to meet a user’s needs.
Put your knowledge into practice — try past paper questions for Computer Science
Testing
The process of checking a program’s behaviour against expected results to find errors and assess whether it meets its requirements.
Correctness
A program’s ability to produce the intended results for valid inputs.
Reliability
A program’s ability to work consistently as intended without failing.
Robustness
A program’s ability to handle unexpected or invalid inputs without crashing or behaving incorrectly.
User requirement
A feature or behaviour that a program must provide to meet a user’s needs.