Test data sets

Designing a program's test data set: a test is an input and an expected result, with nominal cases, boundary cases and error cases, values chosen to reveal defects and a table of tests.

  • 25 cards
  • 5 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios
  5. Understand

A few cards from the deck

  • Test case: what is it?

    Show the answer

    A precise input given to the program, paired with the result it must produce for that input.

    valeur_absolue(-3) must give 3: the test is the pair (-3, 3). A test data set is a list of such pairs, laid out in a table of tests.

  • Which test shows that a version which only checks a % 4 == 0 is wrong?

    ```python
    def est_bissextile(a):
    return a % 4 == 0 and a % 100 != 0 or a % 400 == 0
    `

    • 1900, expected False
    • 2000, expected True
    • 2023, expected False
    • 2024, expected True
    Show the answer

    1900, expected False

    1900 is divisible by 4 but not a leap year, since it is divisible by 100 without being divisible by 400: the simplified version would return True. The other three years give the right result with or without the century rule.

  • A test pairs an … with an …, set before the run.

    Show the answer

    A test pairs an input with an expected result, set before the run.

    Setting the result before running avoids being swayed by the program's output, whether right or not.

  • Expected result: what is it?

    Show the answer

    The value the program must return for a given input, set before running it from the specification.

    It is computed by hand or taken from the specification. Copying it from the program's output would prove nothing: the defect would be copied with it.

  • You are writing a test's expected result. Where should it come from?

    • From the specification or a calculation by hand, before running
    • From the program's output, copied after running it
    • From the result of another function of the same program
    • From the value that seems most likely after a glance at the code
    Show the answer

    From the specification or a calculation by hand, before running

    An expected value copied from the output is always True: if the program is wrong, so is the test. The expected value measures the program because it comes from somewhere other than the program.