Computer Science I / Testing Small Programs
Practice question · Multiple choice

A test asserts that a function returns something, and passes even when the function returns the wrong answer. What has been tested?

Hints
  1. Ask what the assertion would have to say to catch a wrong answer.
  2. This test contributes to coverage. What does that tell you about coverage?
Show the answer

B. That the code ran without raising, which is liveness rather than correctness

Why

It proves the function did not crash, and nothing about the answer. That is the gap coverage metrics cannot see: every line ran, so the report is green, and the assertion never compared anything. A test is only as strong as what it asserts, which is why 'assert not None' is barely a test at all.

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