A bit of context: Earlier today I had to update some SQL code that another colleague of mine provided, and since it’s a pretty large script, it’s stored as a separate file (which is then read and executed at runtime). While doing this I accidentally reintroduced two bugs we had a few months back, namely:
- For whatever reason the ASCII file was encoded in UTF-16 (the colleague emailed me the file, which might have caused it).
- The script was missing initial
SETstatements (required due to some driver things on production, but not on a clean install locally).
After debugging this for about an hour (again) I decided to write some unit tests to ensure this would never happen again (and include a quick way to fix it in the assertion message to provide an easy fix for future developers).
However when I pushed this code another colleague (who is also our team lead) walks up to me and told me I shouldn't make these things again because:
"These things don't belong in unit tests"
"Unit tests should only be used to check the flow of your code"
I’m pretty conflicted now since I still think what I’m doing isn’t wrong, as this bug wouldn’t be reintroduced in the future, however this colleague works as a senior and at the end of the day gets to decide what we spend our time on. What should I do? Am I wrong for doing it this way? Is it considered bad practice?