Friday, December 18, 2020

Urgh Unit Tests

I'm not going to lie. Writing and/or updating unit tests can be incredibly tedious. It's a chore I don't love, but it's a chore that must be done.

The updates I referenced in my prior post have taken on that aspect where you feel like you're unweaving a bunch of code so that you can weave it back together again in a better form. It's a little scary at first because you find yourself wondering "Can I put this mess back together in a reasonable amount of time?"

Basically, the refactor I did to remove the "passthrough" connection class meant that I had to change the constructor of the fairly heavily used "AbstractActiveRecord" class if I wanted the code to continue to enforce the concept of dependency injection. That change has rippled throughout the code and resulted in a lot of unit tests needing to be updated.

And honestly? This is EXACTLY WHY YOU WRITE UNIT TESTS. So that when you make changes to your code in one place you know exactly where those changes require subsequent updates to other code. I just wish it weren't so . . . messy.


No comments:

Post a Comment