<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Khaled Souf</title>
    <description>The latest articles on DEV Community by Khaled Souf (@ksouf).</description>
    <link>https://dev.to/ksouf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F207822%2F0e479869-369b-49b0-97bf-5da16da344d0.jpg</url>
      <title>DEV Community: Khaled Souf</title>
      <link>https://dev.to/ksouf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ksouf"/>
    <language>en</language>
    <item>
      <title>Writing feature files from Zero to Hero. Part 1</title>
      <dc:creator>Khaled Souf</dc:creator>
      <pubDate>Thu, 20 Aug 2020 15:37:49 +0000</pubDate>
      <link>https://dev.to/ksouf/writing-feature-files-from-zero-to-hero-part-1-2jbf</link>
      <guid>https://dev.to/ksouf/writing-feature-files-from-zero-to-hero-part-1-2jbf</guid>
      <description>&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;This article is an introduction to getting Gherkin all the way from User Story.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a gherkin file?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Gherkin is a Business Readable, Domain Specific Language created especially for behavior descriptions. It gives you the ability to remove logic details from behavior tests. Gherkin serves two purposes: serving as your project’s documentation and automated tests.&lt;/em&gt;[Credit Behat Documentation]&lt;/p&gt;

&lt;p&gt;a Gherkin file is defined by two elements a structure and a set of keywords.&lt;/p&gt;

&lt;p&gt;here a basic example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="kd"&gt;Feature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; I want to deposit in my account

 &lt;span class="kn"&gt;Scenario&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; deposit money in my account;
    &lt;span class="nf"&gt;Given &lt;/span&gt;I have a bank account with balance 5000
    &lt;span class="nf"&gt;When &lt;/span&gt;I am depositing 2000 in my account
    &lt;span class="nf"&gt;Then &lt;/span&gt;my balance must be 7000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;the key &lt;code&gt;Feature&lt;/code&gt; defines what your business needs about.&lt;br&gt;
A scenario defines one simple use case it can be a sunny one or even an edge case.&lt;br&gt;
 the rule is to have : &lt;br&gt;
one or several input(s)/ initial state (&lt;code&gt;Given&lt;/code&gt; Clause).&lt;br&gt;
one Call/ user interaction to the system/feature (&lt;code&gt;When&lt;/code&gt; clause) &lt;br&gt;
multiple expected results (&lt;code&gt;Then&lt;/code&gt; Clause)&lt;/p&gt;

&lt;p&gt;if you’d to go deeper here the &lt;a href="https://cucumber.io/docs/gherkin/reference/"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  From User Story to Feature file.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a user story?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MLv7j3NU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1519791883288-dc8bd696e667%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MLv7j3NU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1519791883288-dc8bd696e667%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1950%26q%3D80" alt="user story"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;User stories are short, simple descriptions of a feature told from the perspective of the person who desires the new capability, usually a user or customer of the system. &lt;/p&gt;

&lt;p&gt;They typically follow a simple template:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;As a &amp;lt; type of user &amp;gt;, I want &amp;lt; some goal &amp;gt; so that &amp;lt; some reason &amp;gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;User stories are often written on index cards or sticky notes, stored in a shoebox, and arranged on walls or tables to facilitate planning and discussion.&lt;/em&gt; [Credit Mike Cohn Contributor to Scrum Method]&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;em&gt;As a Customer, I want to deposit money so that can save me money.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Example Mapping.
&lt;/h3&gt;

&lt;p&gt;Usually, as developers, we start developing from a user story to start “the work”.&lt;br&gt;
In my opinion “the work” should start away before.&lt;br&gt;
why? because simply we can’t evaluate what needs to be done accurately.&lt;/p&gt;

&lt;p&gt;one of the approaches to get there is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;identify the story.&lt;/li&gt;
&lt;li&gt;identifying business rules of the user story.&lt;/li&gt;
&lt;li&gt;Creating concrete examples based on business rules for the user story.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;this approach is called &lt;strong&gt;Example mapping&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Example mapping is a workshop that permits to get from a user story a multiple concrete &lt;br&gt;
examples.&lt;/p&gt;

&lt;p&gt;the &lt;strong&gt;Example Mapping&lt;/strong&gt; workshop goes in this order :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;writing the &lt;strong&gt;user story&lt;/strong&gt; and put it in the most upper place of the board using a &lt;strong&gt;yellow card&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;writing the &lt;strong&gt;acceptance criteria&lt;/strong&gt; or &lt;strong&gt;rules&lt;/strong&gt; that we already now just under the user story using &lt;strong&gt;blue cards&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;for each &lt;strong&gt;acceptance criteria&lt;/strong&gt; or &lt;strong&gt;rules&lt;/strong&gt; write a or &lt;strong&gt;multiple scenarios examples&lt;/strong&gt; illustrating it &lt;strong&gt;using green cards&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;sometimes we have &lt;strong&gt;unanswered questions&lt;/strong&gt; so we put on board using &lt;strong&gt;red cards&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the result should be like this :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fo3eRxQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cucumber.io/cucumber/media/blog/ghost/map.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fo3eRxQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cucumber.io/cucumber/media/blog/ghost/map.png" alt="example mappings"&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;if you'd like to go further on the example mappings workshop.&lt;br&gt;
&lt;a href="https://cucumber.io/blog/bdd/example-mapping-introduction/"&gt;here&lt;/a&gt; an excellent of Matt Wynne. &lt;/p&gt;

&lt;p&gt;in the future post I'll talk about writing gherkin files well and all the traps that I've been through in my career.&lt;/p&gt;

&lt;p&gt;Credit for the pictures&lt;br&gt;
&lt;a href="https://unsplash.com/"&gt;unsplash&lt;/a&gt;&lt;br&gt;
&lt;a href="https://cucumber.io/"&gt;cucumber.io&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bdd</category>
      <category>gherkin</category>
      <category>feature</category>
    </item>
  </channel>
</rss>
