DEV Community

Discussion on: What was your TDD aha moment?

Collapse
 
cjbrooks12 profile image
Casey Brooks

My "AHA!" moment has been growing over the past few weeks or so, so I'm still working on getting comfortable with it. But there were several things which all worked to get me hooked:

  1. Spending an afternoon setting up a small suite of integration tests for Orchid which just about doubled its test coverage (~20% to ~40%). Integration tests just for coverage aren't all that useful by themselves, but it did feel quite nice and does give me a small amount of assurance in the codebase that I didn't have before. And having a bit of testing infrastructure in place makes it easier to write more focused unit tests.
  2. Realizing that these integration tests actually documented the behavior of several of Orchid's most foundational plugins quite well, better than just descriptions in Markdown. Markdown docs are needed to tell the story, but as the old saying goes, "a test is worth a thousand words" (or something like that)
  3. When I discovered that one of the plugins wasn't working correctly and I never noticed because Orchid's own documentation didn't hit that edge case, I found I could hand-craft that particular scenario much more easily and and ensure it is fixed properly and stays fixed. This is opposed to setting up the scenario in Orchid's own docs site, fixing the problem, then removing that stuff again, which leaves me with no long-term assurance of the fix.
  4. Orchid is getting big and full build/test runs are starting to be too long for quick, iterative development. In contrast, running individual tests in IntelliJ is very fast and scales much better.
  5. There was a particular data structure I set up early in Orchid's life, and I never really used it much because I couldn't ever get it working properly. But when I fully tested that class I not only fixed those problems, but discovered it is even more useful than my original plans for it and am finding all sorts of really great ways to use it and make Orchid's internals more consistent.