Ensure you test against binary data if appropriate

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the testing category.

Last Updated: 2024-03-02

I had a feature that was tested in my specs against .txt files that contained text data. This same feature, however, was expected to work with binary data in production. Sure enough, it failed with encoding errors in production, due to the file not being opened with the b (for binary) flag.

Lesson

When testing an application that reads files, test against the appropriate category of data (binary vs. text), as you expect to receive.