DEV Community

Oliver Davies
Oliver Davies

Posted on • Originally published at oliverdavies.uk on

TDD doesn't mean you know everything upfront

I'm in the final phase of a Drupal development project for a customer.

It has some custom modules and code I wrote with automated tests and test-driven development.

Today, the client reported a bug.

But, instead of something working incorrectly, this was a use case I hadn't considered.

The tests were passing, but there wasn't one for this.

I wrote the code for the use cases I was aware of when I started, and now I'm aware of another, I can add a test for it and ensure it's tested and working.

To do test-driven development, you don't need to know all the use cases and functionality upfront.

Write for what you know at the time, then expand and iterate in the future.

P.S. If you're creating a new Drupal module, try my free Drupal module template.

Top comments (0)