Day 7

Getting unstuck and the value of testing

Not much to report today. I got a little stuck on an issue with using cookies in my Rails integration tests. I’m trying to use a cookie to sign a user in for testing purposes and something’s not quite working. I need to revisit the testing documentation here and see if that helps clear it up.

I’m hoping that looking at it tomorrow with fresh eyes will bring clarity. It’s easy to get frustrated when something doesn’t click, but you need to find a way to get unstuck. Stepping away for a bit can really help. Showing your work to a friend or colleague can also be helpful. Sometimes all it takes is explaining it to someone else for you to see where the problem is. If I can’t figure it out tomorrow, I’ll try explaining it here and see if that helps.

It sometimes feels like I get stuck more frequently while writing my tests than I do on writing my code, which is really frustrating. I frequently wonder whether it might be better to test differently, test less, or abandon testing altogether.

Much of the value I see in testing is in the long-term confidence it gives me in my code. I’ve written applications with little to no testing before and they reach a complexity tipping-point where unexpected things start breaking when you add new features. It’s difficult to anticipate all the consequences of building and refactoring systems of increasing complexity. There also comes a point with projects that have a long shelf-life when you may (will?) want to start upgrading the underlying libraries or language versions of your application. If you have no tests to make sure your application still works after the upgrade, it will be tougher to catch any bugs that may happen as a result.

Even with firsthand experience of these pain points, I still question the value of testing sometimes, especially for applications in the early/prototype stage. And especially after a day where it feels like I’m banging my head against my test suite instead of getting value from it. I’m trying to solve this by sticking to lightweight integration testing and not getting too carried away. Hoping this will provide a balance of covering the big things and keeping my tests from slowing me down, but the reality is that some days are still going to hurt. It’s just a bit of tough call to say whether it will be worth it in the long run.