Think smaller with TDD

I've recently added several custom search blocks and pages to a client project.

Each requires a results page, a list of autocomplete suggestions for users to select from, a custom form, and a block to place it on the required pages.

For each search, I'm first testing the results page, ensuring it exists and contains the correct results before testing the autocomplete results, creating the block and form, and linking everything together.

Thinking small

This could seem like a large and daunting task, but with test-driven development, I can break everything into smaller, more manageable tasks.

My objective is either to write the next failing test and then get it to pass or to refactor what I've written.

I can focus on these small steps and make progress towards the end goal, guided by the tests I'm writing, instead of needing to focus always on one large and complex task.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.