My API client bugs were mostly bad sample data

I spent a while changing retry logic in a tiny API client because my tests kept failing in different ways. It turned out the sample responses I had saved were inconsistent: one had a missing field, another had an old field name, and one was not even valid JSON.

After I cleaned up the fixtures, the actual client bug was pretty small. I am now treating test data as code instead of random files I happened to save.

  • testing
  • api
  • debugging
23

6 replies · Sort: Best

Best

1 reply from the original poster, shown with the conversation around them.

  1. xiao.si
    4 points

    1 reply

    This is the kind of bug that makes you distrust your own notes for a while. I now keep JSON fixtures tiny on purpose, because once they get...

    41 reply

    This is the kind of bug that makes you distrust your own notes for a while. I now keep JSON fixtures tiny on purpose, because once they get large it’s too easy for one stale field to hide the real problem.

    4
    1. PH
      quietorbitOP
      3 points

      Tiny fixtures helped a lot here too. I was trying to be clever by saving “realistic” responses, but realistic is how you end up debugging old mistakes instead of current code.

      3