In the beginning there was Cucumber (or the Genesis of SpecFlow)

In the beginning there was Cucumber

Really?  I thought it was “In the beginning there was the Word.  And the Word was with God…” etc

That word might have been Cucumber.

Really? I don’t think that’s what John had in mind ….

Alright.  I’m not talking about that beginning.  I’ve moved on a bit.  I am omniscient you know

I’m sorry.  Tell me about this cucumber then.

Cucumber is a tool for writing business readable tests

A bit like unit tests, then?  But for non-Geeks.

Blessed are the geeks

I’m not mocking them.  I’m just saying that unit tests were always a good thing, it was just a shame that only the developers could understand them.

Indeed.   And, Lo, Cucumber was born

I like the sound of this.  You mean I can write a test, a sort of automated acceptance test, and get a product owner… a non-geek… to read and understand it?

Blessed are the product owners, for they shall inherit the system

I guess we could write these acceptance tests first, and give them to the developers as a form of specification?

You can and people already do.  It’s called Acceptance Test Driven Development (ATDD)

Ah, I’m late to the party again….  But this sounds good.  How do I use this Cucumber of which you speak?

Cucumber is the tool for running these tests, but you need a language with which to express your acceptance tests

Another language?  Surely the last thing this industry needs is another language to learn. Are you still trying to confound us over that Babel thing?

This is a simple language.  It has only three words.

That trinity thing again?

What?  Oh yes, very witty….It has only three words and I call it Gherkin

Omniscient?  And that’s the best you can do?  Gherkin?

What’s wrong with the name?

I was getting all excited about Acceptance Test Driven Development, but I’m going to get laughed out of the boardroom if I go in talking about cucumbers and gherkins.

Can we move on?

Just saying

With Gherkin you have just three words.  Given/When/Then.  And you use them like this

Given some pre-condition is true

When I do something

Then some post-condition should be true

I like it

The Given portion is used to assert the pre-conditions that we expect to hold true.  The When portion defines some action…

… and the Then bit must be the post-conditions.  What we expect to be true after the When.

Precisely

Ok.  I like this.  I can see how I can write statements like this to describe the behaviour of the system.  In fact I could even get the domain experts to describe the behaviour with these simple steps.  It could be the specification we give to the developers…

You can and people already do.  It’s called Behaviour Driven Development (BDD)

Ah, late again.  What’s the difference between BDD and ATDD?

Each side has their followers.  Many religious wars have been fought over who is right.  It depresses me, to be honest

Ok.  Sorry to have brought it up.  It doesn’t sound like an important distinction to make.  I mean we’re all trying to move towards the same goal, right?

That’s what I think.  About this and similar matters

But hang-on.  I’ve written all this great Gherkin.  How do I actually run the tests?  These aren’t just going to be “paper” specifications are they? ...that I need to interpret and execute manually?

I’ve had poor experience of people interpreting my words in different ways

Tell me about it

So, how do I turn these into executable tests?

You need to map statements in your testing language to bits of code that perform the actual check or action

Ok.  So if I have a step that says “Given my shopping basket is empty” I have to link that to a bit of code that asserts that the shopping basket is empty?

I can see how that can work.  I wonder if the developers would mind?

I think you’ll find that developers have been evangelising about this for a while.  They will welcome you with open arms

We’re a C# shop.  Does that matter?

No.  You can write Gherkin-style statements in all sorts of languages.  For C# there is a tool called SpecFlow that allows you to write and execute these statements

It gets better.  I can’t wait to get started.

What did you say the tool was called again?

SpecFlow

At last a tool with a name that isn’t going to get me laughed out of the boardroom. 

Thank God for that.

You’re welcome