Solved

Writing tests that would fail on the old code

LiamByteOP

Stage 1 is a cool way to think about tests.

0

Comments 4

Join the discussion

Already have an account? Log in

  1. OllieGrant Solutionreplies: 2

    That's the definition of a regression test: it fails on the buggy version and passes on the fix. Call the function twice without a log and assert each result contains only its own sample — the old version would return both samples on the second call.

    5
    1. LiamByteOPreplies: 1

      Thinking "how would the bug show up?" first, then testing for it. Makes sense.

      0
    2. HenryWrites

      Stage 2 checks the passed-in list is the same object (is) and keeps earlier samples. Good use of is.

      1