{"id":13515,"date":"2017-03-02T00:00:00","date_gmt":"2017-03-02T06:00:00","guid":{"rendered":"https:\/\/centricconsulting.com\/post\/cucumber-introduction-to-gherkin-scripting_sqat-columbus\/"},"modified":"2021-12-15T00:13:50","modified_gmt":"2021-12-15T05:13:50","slug":"cucumber-introduction-to-gherkin-scripting_sqat-columbus","status":"publish","type":"post","link":"https:\/\/centricconsulting.com\/blog\/cucumber-introduction-to-gherkin-scripting_sqat-columbus\/","title":{"rendered":"An Introduction to Gherkin Scripting"},"content":{"rendered":"

Learn about Gherkin Scripting\u00a0in of our\u00a0How-To-Guide on applying Cucumber\u00a0to lead your agile testing team\u00a0down the path to\u00a0automation.<\/h2>\n

Blog four of a series<\/a>.<\/em><\/p>\n

In the 2000s, Dan North created a software development process call Behavior-Driven Development (BDD). In his quest to \u201c<\/a>find a simple and elegant way in Ruby to describe behavior at the application level,<\/a>\u201d<\/a> Dan North created RBehave<\/span>: a story-level BDD framework for Ruby.<\/p>\n

It was in this framework that the Gherkin scripting format was born.<\/p>\n

At a basic level, Gherkin Scripts connect the human concept of cause and effect to the software concept of input\/process\/output. The input is the Given step(s); the process is the When step(s); the output is the Then step(s).<\/p>\n

All scripts, regardless of where they are written or for what system they are written to test, should follow this same format. Or at least have each of these three parts.<\/p>\n

Given<\/h2>\n

The purpose of Given steps is to put the system in a known state before the user (or external system) starts interacting with the system (in the When steps). Some people call the Given steps \u201cPreconditions to the Action.\u201d It is also a common place for data setup.<\/p>\n

Since no functionality should be changing in the Given step, you should rarely have an error in the Given steps. Some Examples:<\/p>\n

<\/a><\/p>\n

When<\/h2>\n

With the system now in the state we need it to be, we can execute the change. The purpose of the When steps are to describe the key action the user performs.<\/p>\n

These are the MONEY<\/em> steps. Or, in other words: the steps that the business is paying you to analyze, build and test. Some examples:<\/p>\n

<\/a><\/p>\n

Then<\/h2>\n

The Then step(s) are the expected results of the When step(s). Its purpose is to observe the outcome of the previous action. Many times the outcome is some kind of output: something that comes out of the system, which has business value.<\/p>\n

This might be a report, a message, navigation to a page, etc. Other times it might be data in a database that has changed or the output from a web service. Either way, it can be quantified. Some examples:<\/p>\n

<\/a><\/p>\n

The Language of the Domain<\/h2>\n

An important aspect of Gherkin scripts is that they are written using the language, terms and definitions of the domain. It has to be \u201cstakeholder-readable.\u201d Stated simply, if a script is written for business acceptance, it should be written so the business users can understand it and follow what is happening.<\/p>\n

If a script is written for an integration test of a web service or a database conversion validation, it should be written so the developers and testers can understand it and follow what is happening. Understanding which domain you are in is very important when writing a Gherkin script.<\/p>\n

Gherkin scripting seems simple: some Given steps to set the test up, a When action step to do something, and a Then step to observe the results of the action.<\/p>\n

But don\u2019t be deceived by their simplicity. Getting a user to the action is not always easy. And business users might not always be clear about the results they expect from the action.<\/p>\n

The power of a well-written Gherkin script is that it facilitates the conversation to make sure it is right.<\/p>\n

It might seem like just another tool in an agile tester\u2019s tool belt. The reality is that Gherkin scripts can be one of the best collaboration tools a tester has.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"

Learn about Gherkin Scripting in of our How-To-Guide on applying Cucumber to lead your agile testing team down the path to automation.<\/p>\n","protected":false},"author":63,"featured_media":25999,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_oasis_is_in_workflow":0,"_oasis_original":0,"_oasis_task_priority":"","_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","footnotes":""},"categories":[1],"tags":[],"coauthors":[15012],"acf":[],"publishpress_future_action":{"enabled":false,"date":"2024-07-21 22:40:42","action":"change-status","newStatus":"draft","terms":[],"taxonomy":"category"},"_links":{"self":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/13515"}],"collection":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/comments?post=13515"}],"version-history":[{"count":0,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/13515\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media\/25999"}],"wp:attachment":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media?parent=13515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/categories?post=13515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/tags?post=13515"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/coauthors?post=13515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}