Project Planning with Specification by Example Approach: How Does It Work
Tags: qa, projectplanning, specificationbyexample, softwaredevelopment
Published: 2019-08-07 16:24:51

---
title: Project Planning with Specification by Example Approach: How Does It Work
cover_image: https://djangostars.com/blog/uploads/2019/07/specification-by-example-post-cover.png
published: true
description: 
tags: #QA, projectplanning, specificationbyexample, softwaredevelopment
canonical_url: https://djangostars.com/blog/ace-project-use-specification-by-example/
---

In software development, almost everyone you work with understands the importance of <a href="https://djangostars.com/services/#quality-assurance" target="_blank" rel="noopener noreferrer">Quality Assurance</a> (QA), but rarely understand the value of engaging QA engineers — especially during early project planning stages. The end result is that a lot of value QA engineers could have provided is simply wasted.

In my experience working as a part of SCRUM development teams with little to no technical specifications and communicating with a non-technical product owner, the role of my QA team has proven to be an essential part of the product development process. Here I’d like to share an effective way to bridge the gap between software development, software quality assurance, and the business with a method called Specifications by Example.

In this article, we aim to focus on the value of QA engineers, especially during a critical project stage: planning.

Let’s dig deeper into how exactly this is done, but before, a few QA fundamentals.

Ideally, it allows to avoid errors in late project delivery stages, saves time and unexpected expenses, decreases the cost of defects (bugs).


The cost of defects depends on the impact they have and when they are found. Usually, the earlier you find one, the less time and effort it takes to fix it. Any error is easier to fix and costs less when you’re still in the requirements or design stage. On the other hand, if you find a defect after the product goes live, error correction may cost much more in terms of both the fixes and the users' reaction.

<img class="alignnone size-full wp-image-1300" src="https://djangostars.com/blog/uploads/2019/07/cost-of-defects.png" alt="qa-development-cost-of-defects" width="1679" height="1325" />

Typically, the Requirements Gathering and Analysis stage (also sometimes called Planning) doesn’t get enough credit within the software development (SDLC) process, even though it can significantly impact a project.

In my view, a QA specialist must be present at all stages (based on Scrum criteria), yet, the requirements for testing and detailed grooming that involve QA engineers aren’t usually handled within early spirits, keeping only to the letter of good Scrum standards but not its spirit.
<h3><a name="2"></a>Maximizing QA Impact During Requirements Gathering and Analysis</h3>
When only product owners, business analysts, and software developers work with the requirements, defects due to poor planning are easier to miss. The importance of the right QA process for software development is illustrated in the cartoon below.

<a href="https://xkcd.com/1425/"><img class="alignnone size-full wp-image-1291" src="https://djangostars.com/blog/uploads/2019/07/the-importance-of-the-right-qa-process.png" alt="" width="1364" height="1003" /></a>

During the first and most critical in terms of impact stage, quality assurance engineers can:
<ul>
 	<li><strong>Expand product knowledge</strong>. By exploring user stories, skeleton models, and papers, QA engineers can get an idea of the work process, figure out the goals of the interested parties, and prepare questions.</li>
 	<li><strong>Reveal logical contradictions</strong>. As soon as QA engineers dive deep into the documentation, their understanding of the project grows and they can spot logical contradictions early in the development process.</li>
 	<li><strong>Address unaddressed elements</strong>. They start noticing flaws in the business process, authorization, and user roles. Poorly defined things like user and input validations and text-field requirements typically become visible to QA engineers early on.</li>
 	<li><strong>Provide user stories feedback</strong>. User stories are brief descriptions of what a product should do for a user, for each of the functions. If the stories are too dense, complicated, or incomplete, they lead to difficulties in coding and preparing test cases. Relying on experience, QA engineers can leave their feedback and suggestions on user stories to make them more accurate</li>
 	<li><strong>Pose questions</strong>. To help address issues, they post questions or point out the flaws they’ve noticed.</li>
</ul>
Including QA engineers early in the software development process prevents many defects and decreases the negative impact on the timeline, budget, and risk.

<h3><a name="3"></a>QA Engineers and Their Role in Communication and Collaboration</h3>
The success of effective collaboration in a software development project lies in clear communication and can be easily achieved by focusing on meeting business goals. Even though QA engineers and software developers each have their own focus, they are still bound by a common objective: to manufacture a reliable, quality product. That’s why we can use a concept called "Three Amigos".

In simple terms, the Three Amigos is a meeting of product owner or business analysts, software developers, and quality assurance engineers to discuss a new feature and refine the specification. From various perspectives, the parties collaborate to determine what they have to do and how they will know that it’s been done correctly (the “Definition of Done” is clear and precise).

The quality assurance engineers have the following role in this process:
<ul>
 	<li>Ask questions while communicating with the business.</li>
 	<li>Analyze the requirements and create test documentation that will prevent ambiguous interpretations during the development stage. Accurate test preparation helps developers avoid bugs and deliver a high-quality product without delays.</li>
 	<li>Suggest that clients review block schemes before sending them to developers.</li>
</ul>
There are many approaches that aim to make planning and requirements gathering more effective for all stakeholders. Behavior-Driven Development (BDD) is one such method worth exploring.
<h3><a name="4"></a>Quality Assurance in Behavior-Driven Development</h3>
Behavior-Driven Development (BDD) implies example-based communication between developers, the QA engineers, and business analysts, or non-technical parties (usually presented by business participants). Ultimately, BDD is meant to improve communication among stakeholders.

<img class="alignnone size-full wp-image-1302" src="https://djangostars.com/blog/uploads/2019/07/behavior-driven-development.png" alt="qa-for-software-development-behavior-driven" width="1966" height="1345" />

The outcome of behavior-driven development example would demonstrate test cases written in a common technical-jargon-free language, which leads to effective collaboration between interested parties. The team may prefer the BDD approach to TDD (test-driven development) for several reasons:
<ul>
 	<li>BDD provides more accurate instructions on how to better arrange conversations between stakeholders.</li>
 	<li>BDD applies “<a href="https://en.wikipedia.org/wiki/5_Whys">Five Whys</a>” — the famous technique used to discover the causal relationships in a specific problem — to each user story so that its purpose becomes definitely related to the business result.</li>
 	<li>BDD comes with a “<a href="https://en.wikipedia.org/wiki/Given-When-Then">Given-When-Then</a>” approach, which refers to a style of writing down test cases for user stories in simple language.</li>
 	<li>BDD contains a variety of tools that address the automatic creation of the technical and end-user documents.</li>
</ul>
Behavior-Driven Development is inevitably linked to another technique called Specification by Example. Both of them use examples to determine how the system should behave. Next, the examples are expressed in a common language that any of the participants can understand, including non-technical members. In some cases, it comes down to Gherkin language that’s intended to help interpret the requirements from the client’s perspective.

Here’s how Specification by Example and Gherkin work.
<h2><a name="5"></a>Specification by Example and Gherkin</h2>
Specification by Example (SbE) is a collaborative technique. It helps determine requirements and functional tests suitable for the needs of a business. The needs are based on recording and illustrating requirements, with explicit examples instead of abstract statements. SbE is applied in terms of Behavior-Driven Development and is especially important for large-scale projects (because it allows managing requirements and functional tests).

<img class="alignnone size-full wp-image-1293" src="https://djangostars.com/blog/uploads/2019/07/specification-by-example.png" alt="qa-development -specification-by-example" width="1450" height="1144" />

Meanwhile, Gherkin refers to DSL (or domain-specific language), which provides a platform for business analysis and end-user testing.
<img class="alignnone size-full wp-image-1292" src="https://djangostars.com/blog/uploads/2019/07/template-comparison.png" alt="qa-development-template-comparison" width="1450" height="1144" />
By giving an idea of how the client sees the requirements, it clarifies a user’s working process and creates explicit conditions that the software must satisfy to meet a user story.

<img class="alignnone size-full wp-image-1296" src="https://djangostars.com/blog/uploads/2019/07/requirements-comparison.png" alt="qa-development-process-requirements-comparison" width="1450" height="1144" />
<h3><a name="6"></a>How Does Specification by Example Work?</h3>
When diving deeper into SbE and considering it in the context of Quality Assurance, it’s important to mention the process patterns that make adjusting software products easy and guarantee that the necessary product is delivered.

Now let’s take a closer look at each of the process patterns and their goals.

<strong>Collaborative Specification</strong>

The objectives of this pattern include:
<ol>
 	<li>getting all necessary roles into the team so that everyone can share their views and contribute to the general understanding;</li>
 	<li>shared responsibility for the project's features and specifications.</li>
</ol>
<strong>Illustrating the Specification Using Examples</strong>

Here’s when a Given-When-Then formula is used for creating testable specs. Upon this pattern, the participants in the development process – including developers, QAs, and a product owner – keep considering the examples until they correspond to the expected behavior of the feature.

<strong>Refining the Specification</strong>

Based on the raw examples and collaborative specification, the product owner creates refined requirements, which are easy for all the stakeholders to understand.

<strong>Automating the Examples</strong>

Using DSL, you can automate testing by displaying clear links between inputs and outputs. While performing test automation, make sure you emphasize specification rather than a scenario. Besides that, the tests should be accurate and easy to understand, hence testable.

<strong>Validating Frequently</strong>

In the deployment pipeline, you can also validate examples every time changes are applied. Additionally, you can expect to have a great number of tools and techniques you can use to ensure product quality. By performing testing as often as possible, you have a chance to reveal weak links at the early stages.

<strong>Living Documentation</strong>

The principle of this pattern is to keep specs easy and precise, evolve them as work progresses, and allow everyone to access the documentation.

<img class="alignnone size-full wp-image-1294" src="https://djangostars.com/blog/uploads/2019/07/specification-by-example-process.png" alt="specification-by-example-process" width="1663" height="1571" />
<h2><a name="7"></a>SbE Examples</h2>
The product owner writes the acceptance criteria if they have a clear understanding and experience in software development and know how to write a project paper. But in most cases, it’s a task for the development team.

For more effective communication, the developers must collaborate with business analysts, the product owner, and a QA engineer. After gathering the whole team, they start working on creating the acceptance criteria.

Let’s consider what steps this process requires:
<h3><a name="8"></a>1. Discussion the acceptance criteria</h3>
Product owner, developers, and quality assurance engineers initially each see acceptance criteria differently. This can lead to miscommunication and defects further on.
<img class="alignnone size-full wp-image-1316" src="https://djangostars.com/blog/uploads/2019/07/discussion-of-acceptance-criteria_1024.png" alt="qa-development-discussion-of-acceptance-criteria" width="1024" height="708" />
<h3><a name="9"></a>2. Illustrating acceptance criteria with examples</h3>
To minimize differences in understanding, a common language format can be used during requirements analysis.

<img class="alignnone size-full wp-image-1297" src="https://djangostars.com/blog/uploads/2019/07/illustrating-acceptance-criteria-with-examples.png" alt="acceptance-criteria-with-examples" width="1654" height="1144" />
<h3><a name="10"></a>3. Discovering hidden assumptions</h3>
To avoid each team member filling in missing data with their own undocumented assumptions the team discusses edge cases, exceptions, and alternative business process and user flows.

<img class="alignnone size-full wp-image-1299" src="https://djangostars.com/blog/uploads/2019/07/discovering-hidden-assumptions.png" alt="QA-for-development-discovering-hidden-assumptions" width="1654" height="1144" />
<h3><a name="11"></a>4. Writing abstract acceptance criteria</h3>
The goal is to arrive at common acceptance criteria that elicit additional clarification questions for non-obvious scenarios.

<img class="alignnone size-full wp-image-1289" src="https://djangostars.com/blog/uploads/2019/07/writing-abstract-acceptance-criteria.png" alt="qa-development-writing-abstract-acceptance-criteria" width="1654" height="1144" />
<h3><a name="12"></a>5. Working on examples of acceptance criteria</h3>
Augment the abstract criteria with real-life examples and clear acceptance criteria that anyone can understand.

<img class="alignnone size-full wp-image-1315" src="https://djangostars.com/blog/uploads/2019/07/working-on-examples-of-acceptance-criteria_1024.png" alt="qa-development-working-on-examples-of-acceptance-criteria" width="1024" height="708" />
<h2><a name="13"></a>The Benefits of Acceptance Criteria</h2>
Different kinds of methodologies and approaches aim to bridge the communication gap in the project lifecycle. Using Specifications by Example, each party involved in the development process can significantly benefit from using any of them. And by adding acceptance criteria into the mix, all participants win. Here’s exactly how each party benefits from writing them:

<strong>Product Owner:</strong>
<ul>
 	<li>Expands and validates the requirements</li>
 	<li>Clarifies negative cases</li>
 	<li>Has a clear understanding of business goals and provides the team with early feedback (resulting in a better alternative decision than the developers would have chosen)</li>
</ul>
<strong>Software Developers:</strong>
<ul>
 	<li>Ensure the requirements are explicit and lack functional gaps</li>
 	<li>Keep up with the business goal, which allows them to stay motivated to find the proper solution</li>
 	<li>Write better code due to their clear understanding of test case dependencies, which allows them to offer better alternative architectural designs</li>
</ul>
<strong>QA Engineers:</strong>
<ul>
 	<li>Build quality early on in the development process and help create a better-quality product as a result</li>
 	<li>Provide ready test scripts for user acceptance testing</li>
 	<li>Offer formalized testing formats that are perfectly suited for automated testing</li>
 	<li>Prevent development errors, as long as the developers clearly understand which specific criteria their code will be tested against</li>
</ul>
<h2><a name="14"></a>Closing Thoughts on Specifications by Example</h2>
Including QA engineers from the very beginning of a project has a lot of benefits, from saved time and money to fewer bugs in the final stages. All of this leads to one major advantage — the ability to deliver a high-quality product that meets all the client’s requirements and business needs.

Besides, QA engineers play a significant role in communication and collaboration with all the stakeholders who participate in software development. It is important for them to communicate throughout the software development process, especially when many approaches and techniques are or might be used to improve communication (e.g., Three Amigos, Specification by Example, etc.).

While seeking to build a high-quality product that will meet business needs, I suggest you give Specification by Example a try. It accentuates shared understanding and allows the team to determine a single source of truth. Using this collaborative approach, the stakeholders can automate the writing of acceptance criteria and focus on preventing defects.

If you apply QA testing to the Requirements Gathering and Analysis stage, you’ll be able to prevent defects in design from being coded into the software. At this stage, QA deeply learns the documentation along with the requirements, monitors whether they are met and not skipped over by developers, ensures business problems are resolved, and reveals contradictions and unaddressed elements. Hence, QA is an essential part of requirements management.

And finally, if you’re a part of the development team, keep in mind the following:
<ol>
 	<li>A formulaic approach to planning without working through goals and aims doesn’t lead to great product results.</li>
 	<li>There is no magic pill — try different methods in your specific process; don’t cling on to a single one.</li>
 	<li>Each team has its own optimal blend of approaches. If one doesn’t work for you, go for another methodology.</li>
 	<li>It is important to experiment and modify the elements until they work for you.</li>
 	<li>All team members with different competencies should take part in the planning process to create a fuller picture of the requirements.</li>
</ol>

This article about [project planning with specification by example approach](https://djangostars.com/blog/ace-project-use-specification-by-example/) is written by Irina Meshchankina - QA Lead at Django Stars. Originally posted on [Django Stars blog](https://djangostars.com/blog/).