Computer Science I / Testing Small Programs
Practice question · Put in order

Order the steps of writing and running one test case.

Hints
  1. A test case is a pair: an input and the output it should produce.
  2. The expected output must be worked out independently, not read off the program's own result.
Show the answer
  1. Choose an input to test
  2. Work out the expected output independently, by hand
  3. Run the program on that input
  4. Compare the actual output with the expected output
Why

Pick an input, decide the expected output independently, run, then compare. Working out the expected result independently is essential, if you take the answer from the program itself, the test can never catch a wrong answer.

Read the lesson: Testing Small Programs →

Practise Testing Small Programs

The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Testing Small Programs