{"id":259,"date":"2023-10-28T18:37:32","date_gmt":"2023-10-28T18:37:32","guid":{"rendered":"http:\/\/localhost:10048\/?p=259"},"modified":"2023-10-28T18:37:32","modified_gmt":"2023-10-28T18:37:32","slug":"given-when-then-gherkin-syntax-in-bdd","status":"publish","type":"post","link":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/","title":{"rendered":"Given-When-Then (Gherkin) Syntax in BDD"},"content":{"rendered":"\n

Given-When-Then, often referred to as Gherkin syntax, is a structured language used in Behavior-Driven Development (BDD) to define and describe the expected behavior of a software system. Gherkin syntax is designed to be human-readable and is commonly used in BDD frameworks like Cucumber and SpecFlow. It provides a clear and uniform way to express behavior scenarios.<\/p>\n\n\n\n

The Gherkin Structure:<\/strong><\/p>\n\n\n\n

Gherkin scenarios follow a specific structure with three main sections: Given, When, and Then. Each section serves a distinct purpose in describing the expected behavior.<\/p>\n\n\n\n

    \n
  1. Given:<\/strong><\/li>\n<\/ol>\n\n\n\n
      \n
    • The “Given” section describes the initial context or state of the system before the behavior is tested.<\/li>\n\n\n\n
    • It sets up the preconditions necessary for the scenario to make sense.<\/li>\n\n\n\n
    • “Given” statements establish the starting point for the behavior you want to test.<\/li>\n<\/ul>\n\n\n\n
        \n
      1. When:<\/strong><\/li>\n<\/ol>\n\n\n\n
          \n
        • The “When” section describes an action or event that occurs, typically triggered by the user or some external factor.<\/li>\n\n\n\n
        • It represents the action you are testing\u2014the specific behavior that you want to observe or verify.<\/li>\n<\/ul>\n\n\n\n
            \n
          1. Then:<\/strong><\/li>\n<\/ol>\n\n\n\n
              \n
            • The “Then” section describes the expected outcome or behavior that should result from the action defined in the “When” section.<\/li>\n\n\n\n
            • “Then” statements articulate the specific results, changes, or behavior that you are testing for.<\/li>\n<\/ul>\n\n\n\n

              Example Using Gherkin Syntax:<\/strong><\/p>\n\n\n\n

              Here’s an example of a BDD scenario written in Gherkin syntax:<\/p>\n\n\n\n

              Scenario: Logging into an email account\n\nGiven the user is on the email login page\nWhen the user enters their valid username and password\nThen the user should be logged into their email account<\/code><\/pre>\n\n\n\n

              In this scenario:<\/p>\n\n\n\n

                \n
              • The “Given” section establishes the context by placing the user on the email login page.<\/li>\n\n\n\n
              • The “When” section describes the action of entering a valid username and password.<\/li>\n\n\n\n
              • The “Then” section specifies the expected outcome, which is that the user should be successfully logged into their email account.<\/li>\n<\/ul>\n\n\n\n

                Additional Keywords in Gherkin:<\/strong><\/p>\n\n\n\n

                In addition to the primary Given-When-Then structure, Gherkin syntax also includes other keywords that can be used to enhance scenarios:<\/p>\n\n\n\n

                  \n
                • And:<\/strong> The “And” keyword can be used to continue a section that has already started. For example, “Given,” “When,” or “Then” can be followed by “And” to add more context, actions, or expected outcomes.<\/li>\n\n\n\n
                • But:<\/strong> The “But” keyword is similar to “And” but is often used to introduce an unexpected outcome or exception.<\/li>\n\n\n\n
                • Background:<\/strong> The “Background” keyword is used to define a set of Given steps that are common to multiple scenarios within the same feature file. This helps avoid repetition and keeps feature files concise.<\/li>\n\n\n\n
                • Scenario Outline:<\/strong> The “Scenario Outline” keyword is used to create parameterized scenarios. It allows you to run the same scenario with different sets of data.<\/li>\n<\/ul>\n\n\n\n

                  Gherkin syntax provides a standardized and human-readable way to express behavior scenarios in BDD. By following this structure, development teams can create clear, structured, and unambiguous descriptions of how the software should behave from the user’s perspective.<\/p>\n","protected":false},"excerpt":{"rendered":"

                  Given-When-Then, often referred to as Gherkin syntax, is a structured language used in Behavior-Driven Development (BDD) to define and describe the expected behavior of a software system. Gherkin syntax is designed to be human-readable and is commonly used in BDD frameworks like Cucumber and SpecFlow. It provides a clear and uniform way to express behavior […]<\/p>\n","protected":false},"author":1,"featured_media":260,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"material-hide-sections":[],"footnotes":""},"categories":[1],"tags":[],"yoast_head":"\nGiven-When-Then (Gherkin) Syntax in BDD | Sean Dinwiddie<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Given-When-Then (Gherkin) Syntax in BDD | Sean Dinwiddie\" \/>\n<meta property=\"og:description\" content=\"Given-When-Then, often referred to as Gherkin syntax, is a structured language used in Behavior-Driven Development (BDD) to define and describe the expected behavior of a software system. Gherkin syntax is designed to be human-readable and is commonly used in BDD frameworks like Cucumber and SpecFlow. It provides a clear and uniform way to express behavior […]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/\" \/>\n<meta property=\"og:site_name\" content=\"Sean Dinwiddie\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/seanpaulpaynedinwiddie\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-28T18:37:32+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/localhost:10048\/wp-content\/uploads\/2023\/10\/pexels-dominykas-s-6858311-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1440\" \/>\n\t<meta property=\"og:image:height\" content=\"2560\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"seandinwiddie\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@seandinwiddie\" \/>\n<meta name=\"twitter:site\" content=\"@seandinwiddie\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"seandinwiddie\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t \"@context\": \"https:\/\/schema.org\",\n\t \"@graph\": [\n\t {\n\t \"@type\": \"Article\",\n\t \"@id\": \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#article\",\n\t \"isPartOf\": {\n\t \"@id\": \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/\"\n\t },\n\t \"author\": {\n\t \"name\": \"seandinwiddie\",\n\t \"@id\": \"http:\/\/localhost:10048\/#\/schema\/person\/902c3ac2feab4b4f79613cac495c132a\"\n\t },\n\t \"headline\": \"Given-When-Then (Gherkin) Syntax in BDD\",\n\t \"datePublished\": \"2023-10-28T18:37:32+00:00\",\n\t \"dateModified\": \"2023-10-28T18:37:32+00:00\",\n\t \"mainEntityOfPage\": {\n\t \"@id\": \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/\"\n\t },\n\t \"wordCount\": 444,\n\t \"commentCount\": 0,\n\t \"publisher\": {\n\t \"@id\": \"http:\/\/localhost:10048\/#organization\"\n\t },\n\t \"articleSection\": [\n\t \"Development\"\n\t ],\n\t \"inLanguage\": \"en-US\",\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"CommentAction\",\n\t \"name\": \"Comment\",\n\t \"target\": [\n\t \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#respond\"\n\t ]\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"WebPage\",\n\t \"@id\": \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/\",\n\t \"url\": \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/\",\n\t \"name\": \"Given-When-Then (Gherkin) Syntax in BDD | Sean Dinwiddie\",\n\t \"isPartOf\": {\n\t \"@id\": \"http:\/\/localhost:10048\/#website\"\n\t },\n\t \"datePublished\": \"2023-10-28T18:37:32+00:00\",\n\t \"dateModified\": \"2023-10-28T18:37:32+00:00\",\n\t \"breadcrumb\": {\n\t \"@id\": \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#breadcrumb\"\n\t },\n\t \"inLanguage\": \"en-US\",\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"ReadAction\",\n\t \"target\": [\n\t \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/\"\n\t ]\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"BreadcrumbList\",\n\t \"@id\": \"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#breadcrumb\",\n\t \"itemListElement\": [\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 1,\n\t \"name\": \"Home\",\n\t \"item\": \"http:\/\/localhost:10048\/\"\n\t },\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 2,\n\t \"name\": \"Given-When-Then (Gherkin) Syntax in BDD\"\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"WebSite\",\n\t \"@id\": \"http:\/\/localhost:10048\/#website\",\n\t \"url\": \"http:\/\/localhost:10048\/\",\n\t \"name\": \"Sean Dinwiddie\",\n\t \"description\": \"Software Development\",\n\t \"publisher\": {\n\t \"@id\": \"http:\/\/localhost:10048\/#organization\"\n\t },\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"SearchAction\",\n\t \"target\": {\n\t \"@type\": \"EntryPoint\",\n\t \"urlTemplate\": \"http:\/\/localhost:10048\/?s={search_term_string}\"\n\t },\n\t \"query-input\": \"required name=search_term_string\"\n\t }\n\t ],\n\t \"inLanguage\": \"en-US\"\n\t },\n\t {\n\t \"@type\": \"Organization\",\n\t \"@id\": \"http:\/\/localhost:10048\/#organization\",\n\t \"name\": \"Sean Dinwiddie\",\n\t \"url\": \"http:\/\/localhost:10048\/\",\n\t \"logo\": {\n\t \"@type\": \"ImageObject\",\n\t \"inLanguage\": \"en-US\",\n\t \"@id\": \"http:\/\/localhost:10048\/#\/schema\/logo\/image\/\",\n\t \"url\": \"http:\/\/localhost:10048\/wp-content\/uploads\/2023\/10\/cropped-cropped-PhotoReal_a_watercooled_gaming_PC_case_of_temperaturecontrolle_0-1.jpg\",\n\t \"contentUrl\": \"http:\/\/localhost:10048\/wp-content\/uploads\/2023\/10\/cropped-cropped-PhotoReal_a_watercooled_gaming_PC_case_of_temperaturecontrolle_0-1.jpg\",\n\t \"width\": 512,\n\t \"height\": 512,\n\t \"caption\": \"Sean Dinwiddie\"\n\t },\n\t \"image\": {\n\t \"@id\": \"http:\/\/localhost:10048\/#\/schema\/logo\/image\/\"\n\t },\n\t \"sameAs\": [\n\t \"https:\/\/www.facebook.com\/seanpaulpaynedinwiddie\/\",\n\t \"https:\/\/twitter.com\/seandinwiddie\",\n\t \"https:\/\/linkedin.com\/in\/seandinwiddie\",\n\t \"https:\/\/github.com\/seandinwiddie\",\n\t \"https:\/\/www.instagram.com\/seanpaulpaynedinwiddie\/\"\n\t ]\n\t },\n\t {\n\t \"@type\": \"Person\",\n\t \"@id\": \"http:\/\/localhost:10048\/#\/schema\/person\/902c3ac2feab4b4f79613cac495c132a\",\n\t \"name\": \"seandinwiddie\",\n\t \"image\": {\n\t \"@type\": \"ImageObject\",\n\t \"inLanguage\": \"en-US\",\n\t \"@id\": \"http:\/\/localhost:10048\/#\/schema\/person\/image\/\",\n\t \"url\": \"http:\/\/2.gravatar.com\/avatar\/e66a6738e9c0b2419c8f71725b6d5a19?s=96&d=mm&r=g\",\n\t \"contentUrl\": \"http:\/\/2.gravatar.com\/avatar\/e66a6738e9c0b2419c8f71725b6d5a19?s=96&d=mm&r=g\",\n\t \"caption\": \"seandinwiddie\"\n\t },\n\t \"sameAs\": [\n\t \"http:\/\/localhost:10048\"\n\t ],\n\t \"url\": \"http:\/\/localhost:10048\/author\/seandinwiddie\/\"\n\t }\n\t ]\n\t}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Given-When-Then (Gherkin) Syntax in BDD | Sean Dinwiddie","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/","og_locale":"en_US","og_type":"article","og_title":"Given-When-Then (Gherkin) Syntax in BDD | Sean Dinwiddie","og_description":"Given-When-Then, often referred to as Gherkin syntax, is a structured language used in Behavior-Driven Development (BDD) to define and describe the expected behavior of a software system. Gherkin syntax is designed to be human-readable and is commonly used in BDD frameworks like Cucumber and SpecFlow. It provides a clear and uniform way to express behavior […]","og_url":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/","og_site_name":"Sean Dinwiddie","article_publisher":"https:\/\/www.facebook.com\/seanpaulpaynedinwiddie\/","article_published_time":"2023-10-28T18:37:32+00:00","og_image":[{"width":1440,"height":2560,"url":"http:\/\/localhost:10048\/wp-content\/uploads\/2023\/10\/pexels-dominykas-s-6858311-scaled.jpg","type":"image\/jpeg"}],"author":"seandinwiddie","twitter_card":"summary_large_image","twitter_creator":"@seandinwiddie","twitter_site":"@seandinwiddie","twitter_misc":{"Written by":"seandinwiddie","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#article","isPartOf":{"@id":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/"},"author":{"name":"seandinwiddie","@id":"http:\/\/localhost:10048\/#\/schema\/person\/902c3ac2feab4b4f79613cac495c132a"},"headline":"Given-When-Then (Gherkin) Syntax in BDD","datePublished":"2023-10-28T18:37:32+00:00","dateModified":"2023-10-28T18:37:32+00:00","mainEntityOfPage":{"@id":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/"},"wordCount":444,"commentCount":0,"publisher":{"@id":"http:\/\/localhost:10048\/#organization"},"articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/","url":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/","name":"Given-When-Then (Gherkin) Syntax in BDD | Sean Dinwiddie","isPartOf":{"@id":"http:\/\/localhost:10048\/#website"},"datePublished":"2023-10-28T18:37:32+00:00","dateModified":"2023-10-28T18:37:32+00:00","breadcrumb":{"@id":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/localhost:10048\/given-when-then-gherkin-syntax-in-bdd\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/localhost:10048\/"},{"@type":"ListItem","position":2,"name":"Given-When-Then (Gherkin) Syntax in BDD"}]},{"@type":"WebSite","@id":"http:\/\/localhost:10048\/#website","url":"http:\/\/localhost:10048\/","name":"Sean Dinwiddie","description":"Software Development","publisher":{"@id":"http:\/\/localhost:10048\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/localhost:10048\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/localhost:10048\/#organization","name":"Sean Dinwiddie","url":"http:\/\/localhost:10048\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/localhost:10048\/#\/schema\/logo\/image\/","url":"http:\/\/localhost:10048\/wp-content\/uploads\/2023\/10\/cropped-cropped-PhotoReal_a_watercooled_gaming_PC_case_of_temperaturecontrolle_0-1.jpg","contentUrl":"http:\/\/localhost:10048\/wp-content\/uploads\/2023\/10\/cropped-cropped-PhotoReal_a_watercooled_gaming_PC_case_of_temperaturecontrolle_0-1.jpg","width":512,"height":512,"caption":"Sean Dinwiddie"},"image":{"@id":"http:\/\/localhost:10048\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/seanpaulpaynedinwiddie\/","https:\/\/twitter.com\/seandinwiddie","https:\/\/linkedin.com\/in\/seandinwiddie","https:\/\/github.com\/seandinwiddie","https:\/\/www.instagram.com\/seanpaulpaynedinwiddie\/"]},{"@type":"Person","@id":"http:\/\/localhost:10048\/#\/schema\/person\/902c3ac2feab4b4f79613cac495c132a","name":"seandinwiddie","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/localhost:10048\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/e66a6738e9c0b2419c8f71725b6d5a19?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/e66a6738e9c0b2419c8f71725b6d5a19?s=96&d=mm&r=g","caption":"seandinwiddie"},"sameAs":["http:\/\/localhost:10048"],"url":"http:\/\/localhost:10048\/author\/seandinwiddie\/"}]}},"_links":{"self":[{"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/posts\/259"}],"collection":[{"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":1,"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":261,"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/posts\/259\/revisions\/261"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/media\/260"}],"wp:attachment":[{"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:10048\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}