Skip navigation

The Suspension of Test-Driven Disbelief

I tend to see the Test- and Behavior-Driven Development conversion process with all of the “aha! moments” along the way of as very akin to an act of faith: a trust fall.

Remember the scene from Indiana Jones and the Last Crusade when Indy, just prior to entering the Grail chamber, comes to a seemingly impassable subterranean chasm? He realizes the nature of the test (act of faith), closes his eyes, puts one foot forward, and takes the plunge. Of course, our hero doesn’t plummet to his death; he finds himself suspended on a cleverly camouflaged bridge (damn those medieval engineers were good). The path was there the whole time.

So, okay, how is TDD like this? Properly installing it into your daily repertoire requires forming a habit. Doing primarily interaction-based, BDD-style testing requires taking that step into the unknown. Sure you can take the recommendations of others, but until you will yourself to make the move, until your foot actually hits that nigh-invisible bridge, you won’t be sure of your footing.

Wikipedia defines suspension of disbelief as:

Suspension of disbelief… refers to the alleged willingness of a reader or viewer to accept as true the premises of a work of fiction, even if they are fantastic, impossible, or contradictory. It also refers to the willingness of the audience to overlook the limitations of a medium, so that these do not interfere with the acceptance of those premises.

This concept, at least in spirit as we’re not dealing with fiction here, is a necessary precondition to sticking with and getting success from proper TDD. It may seem a strange and backward way of doing things and the Unit Tests that come out of the BDD style will look just plain strange compared to the state-based and assertion heavy style you might be used to. It’s repeating Indy’s first step dozens of times and gaining a bit of confidence each time.

One of these steps inevitably comes when you’re trucking along in the Red-Green-Refactor cycle, mocking this collaborator and stubbing that collaborator and you notice: “Hey, there are interfaces without implementation! How can I run/debug my project?”

Check your disbelief at the door, stay in the cycle, and wait for the payoff. A bit further down the path, when you’ve finished the story and tests are passing, you’ll all of a sudden have a working, shippable, F5-able feature without ever having hit the debugger. Realizing this for the first time ought to bring a smile to your face that rivals any popcorn movie.

One Trackback/Pingback

  1. [...] David Laribee speaks about the suspension of disbelief to those who have never tried TDD, afraid to make the leap of faith: “Check your disbelief at [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*