@cucumber should_​behave like “I want”

When I first heard about test-​​driven devel­op­ment, it not only made per­fect sense, I real­ized it was some­thing I had been try­ing to imple­ment (with­out the ben­e­fit of dynamic auto­mated tests) by had in weird-​​ass lan­guages like Pro­graph and R. Hear­ing about it just made sense, though it took me some time to climb on board the lan­guages in which it was (back then) sim­plest to implement.

But I never got over the ass-​​backwardsness of assertion-​​driven TDD’s work­flow: the sense that every unit test is a lit­tle magic trick. “Observe, as I cre­ate this NewOb­ject. [applause] Noth­ing inside, noth­ing out­side! I assert that NewObject.inside is aValue. No? It is not? [amused laugh­ter] But where is aValue? Ah… but watch, watch care­fully as I type, and… voila! My asser­tion is now cor­rect!”

Close. I under­stand, I under­stood, I had been try­ing to do some­thing like that in many ways, back long long ago.

But not quite. Espe­cially, I’ve found, for the accu­mu­la­tion of unwrit­ten tests. Yes, as you move for­ward with tra­di­tional test-​​driven devel­op­ment you will think of other things you should do. It should check for errors. It should fail grace­fully when it can’t con­nect to the pipe. It should be an inte­ger, not a float. &c &c

A while back (more than a year?), I installed and worked for a while with rspec and cucum­ber. I had been lured to Ruby years back by Ron and Chet, but never really got too far along my path that way. This was… different.

And then, a big bunch of Python. That’s slowed down, and now with Bar­bara I’m com­ing back to Ruby (and Rails, but not so much as Merb). And BDD is there, ready for me, and greatly improved.

No, really: rspec is exactly how the small­est incre­ment of auto­mated test-​​driven unit test­ing should work. Cucum­ber is [almost] exactly the way the small­est, sim­plest incre­ment of auto­mated accep­tance test-​​driven project man­age­ment should work.

The prob­lem? The rit­u­als of file link­ing. You have a specs file; you have a fea­tures file; you have a steps file; you have your actual code; you have your helper files.… Some­where in that mess, you have a mesh of spaghetti, all sorts of stuff refer­ring to other stuff. And that’s con­fus­ing. A lit­tle, teeny bit dis­ap­point­ing, even.

Don’t get me wrong: the lat­est rspec/​cucumber release is the next res­o­nant “yes” in a chain of sub­stan­tial improve­ments in the way code can be writ­ten. Because with rspec you can grace­fully and com­mu­nica­tively catch those inci­den­tals: “it ‘should check for errors’… it ‘should fail grace­fully’” You can say that in rspec’s cun­ning frame­work; you can let the cus­tomer say what it is they want, with Cucumber.

One thought on “@cucumber should_​behave like “I want”

  1. Pingback: Notional Slurry » If I titled this the way I wanted, it might crash my server

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>