tdd

Is Test Driven Development in Drupal possible?

I was searching for a way to make test writing for Media a little less painful.  I use TDD in Ruby, Python and even in PHP projects I did before coming to Drupal (5 years ago).  It pains me that I'm unable to find a way to do it in Drupal.  I read a fantastic writeup by a dedicated TDD engineer trying to switch to Drupal

"One minute per test case when I'm expecting to easily more than a hundred test cases feels insane."

I personally agree.  And I'm not going to spend a few hours setting up mysql on a RAM disk just to go from 3 minute runs to 1.5 minute runs.  The only answer is of course unit testable code which for any substantial module means a unit testable framework, which we really don't have.  

So if we're going to rely on functional tests, we can kiss TDD goodbye.  What is the long term solution here then?  Can we make D8 more pluggable so we can use mocks around cleaner interfaces to avoid this?  The issue is that Drupal's USP is you can mess with anything anywhere… as soon as you start introducing mocks, you kinda lose that which means the tests aren't as sound.

Maybe the answer is Simpletest 2 which allows you to run on a "dirty" environment.

Tags: 

Subscribe to tdd