So I've started writing unit tests as a standard part of my development workflow. I'm still relatively new to it, and I'm only testing parts of my application that I need to be completely solid, but I'm already observing two changes to my process:
1. Taking the extra time to pull things into their own classes, write proper naming, etc so that I can actually test units individually makes sense now, from a time/effort/cost perspective.
2. On the projects where I do unit testing, I've caught 100% of regression bugs before they became a production issue. The immediate angry red text feedback incentivizes me to take more care when refactoring/renaming things, so I end up doing a more thorough job of that overall.
Mostly, the thing that got me testing was a paradigm shift, from: "Ugh, you mean I have to write even more code than I've already written?"

To: "So I can run one command to execute everything in my program at once? And find errors before users do?"
For the most part, the people/blog posts/etc that evangelize testing seem to focus on the shiny tools, new modules, pretty error pages, cool features to navigate to the bugs, etc.

The real value is: not having to answer the phone at 11pm because some edge case broke in prod.
I think if testing was sold to me like that upfront ("Hey kid, wanna get some sleep at night?") I'd have adopted it years ago.
You can follow @WoganMay.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: