[LRUG] Writing readable feature tests with RSpec

Graham Ashton graham at effectif.com
Mon Jul 28 06:26:04 PDT 2014


On 28 Jul 2014, at 10:27, Anthony Green <anthony.charles.green at gmail.com> wrote:

> Early adopters at the cultural core of BDD today push forward into new areas. Dan North with 'accelerated agile'  Liz Keogh and Chris Matts with 'Cynefin'.

I saw Liz Keogh give a talk at at Nordevcon this year, entitled “10 years of Doing Behaviour-Driven Development All Wrong”.

She (along with Dan North) was one of the core developers of jBehave, which is where the ideas that lead to Gherkin and Cucumber first saw the light of day.

Liz told us that she and Dan both came (independently) to the same conclusion relatively recently: Writing scenarios is useful, but automating them is a big mistake.

That’s quite a statement.

The point of writing scenarios was to enable “discovery”. To drive conversations with stakeholders that would uncover what a product really ought to do, and to do it early before time is spent committing to your ideas in code.

With Cucumber, what they’ve observed in the wild is developers sitting down and writing Gherkin in relative isolation. By writing scenarios on their own, Liz has observed developers to be:

1. Skipping the discovery step, and writing scenarios that don’t reflect the actual requirements.

2. Committing to these mistakes early (code is a commitment).

3. Using a framework that makes it particularly difficult to refactor that code later (i.e. automating Gherkin is a bigger commitment to a bad plan than writing conventional tests would have been).

4. Confident (falsely) that they’re solving the right problem, because they’re using BDD.

In other words (these are direct quotes) “BDD is building software that matters” and “Gherkin is the worst thing to happen to BDD”.

My notes also contain the telling line “BDD gave people the illusion that you could specify everything with scenarios”.

In this talk Liz provided the first feasible explanation for something that has had me nonplussed for years: Why did so many bright people, for whom I have a lot of respect, continue to use and promote Cucumber, while I found it to be an utter waste of time (and therefore money)?

Maybe scenarios gave them confidence that they were solving the right problem, a feeling that they’d otherwise been missing?

I do my “discovery" long before I get near an editor. I sit down with stakeholders, sketch things on paper, ask lots of questions and do everything I can to find out where their expectations don’t tally with mine. Then I write story cards (not in the limiting “As a potato...” form - in proper English, like a grown up) that describe *why* we’re building what we’re building. I if I can’t explain the why, I haven’t asked enough questions.

If I were to sit down and write scenarios having had those conversations, they’d have nothing left to teach me. Scenarios and Cucumber consequently feel like dead weight *to me*.

If you don’t enjoy working the way I’ve just described I can imagine that writing scenarios could be a useful way to trigger discussions that would save a lot of time. Once you’ve had those discussions, there’s no reason to waste time using them as a basis for integration tests - I feel that job is better left to a proper testing framework.

The only solid conclusion I can draw from all these differing opinions is that there’s more than one way to skin a cat!


-- 
Graham Ashton
Founder, Agile Planner
https://www.agileplannerapp.com | @agileplanner | @grahamashton




More information about the Chat mailing list