Gherkin – It ain’t just a Pickle!

 

I know, I know — as a developer I’m supposed to embrace learning new languages and tools, as such things can introduce improvements to productivity and code quality. Nevertheless, when I recently aimed to learn Behavior Driven Development (“BDD“), I was less than enthusiastic about having to learn yet another set of tools and confused by the plethora of software associated with it.

However, in my BDD travels I encountered a common language denominator – Gherkin – which made assimilating the methodology much easier.  A bit of background.  Gherkin does one thing and just one thing only (in tech-speak it’s a “domain specific language” ).  In BDD, clients and developers write “user stories” to define the behavior required of a computer application. Having application development driven by these stories helps ensure that the application does what the client needs it to do.

That’s where Gherkin comes in. It’s not only a pickled cucumber with a funny name, it’s also a simple language that clients and developers use together to to write those user stories. The cool thing about using a language like Gherkin for the stories is that once done, the sentences in the stories can be attached to actual integration and acceptance test code.  As a result,  the whole test process can be automated.

Another good thing about Gherkin is that it is the language used in many of the more popular BDD tools and across programming languages.  It’s kind of like the Esperanto of BDD!  Here are some examples of language/BDD tool pairings using Gherkin:

  • Ruby/Cucumber
  • PHP/Behat
  • Java/Cucumber-jvm
  • JavaScript/Cucumber.js
  • .Net/SpecFlow
  • PythonBehave

And last but not least, Gherkin is the simplest language you’ll ever come across. Check out this example (bolded terms are Gherkin portion):

Scenario: Search the web for a search term on Google
Given: I am on the Google home page
When: I enter search text into the search text box
And: I click the Google Search button
Then: I should get a list of web content related to my search terms

That’s it. That’s practically the entire language (there are a few more keywords, but you get the idea).

So I don’t actually have much to complain about when it comes to do Behavior Driven Development, do I? That’s because Gherkin is easy for both the developer and the client.  And no matter where I may roam programming-wise, Gherkin may be there to meet me.

Endertech is a Los Angeles Software Development Company able to provide solutions for your project’s development needs. Contact us for your free consultation.

- Endertech Alumnus | 

Filed under: <Development>