![Page 1: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/1.jpg)
Specifications for the real world Specification by Example and Gherkin
Kamil Nicieja [email protected]
![Page 2: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/2.jpg)
Kamil Nicieja
1. a product manager
2. co-founder & CEO at Ada
http://www.adaonline.pl
3. author of “Writing Great Specifications”
![Page 3: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/3.jpg)
Specifica.on is
1. a document
2. which contains requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
![Page 4: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/4.jpg)
Why care?
![Page 5: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/5.jpg)
An analysis issued by Great Britain's Health and Safety Executive suggests that
44% of system failures may have their root cause in an inadequate
specification.
Bell Labs and IBM studies have determined that 80% of all defects are
inserted in the requirements phase.
Why care?
![Page 6: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/6.jpg)
An analysis issued by Great Britain's Health and Safety Executive suggests that
44% of system failures may have their root cause in an inadequate
specification.
Bell Labs and IBM studies have determined that 80% of all defects are
inserted in the requirements phase.
Commercial organizations across the European Union lost 142 billion EUR on
failed IT projects in 2004 alone, mostly because of poor alignment with
business objectives or business strategies becoming obsolete during delivery.
Why care?
![Page 7: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/7.jpg)
We’re doing something wrong.
![Page 8: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/8.jpg)
Specification anti-patterns
![Page 9: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/9.jpg)
Specification anti-patterns
Over-specification
![Page 10: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/10.jpg)
Specification anti-patterns
Over-specification Hand-offs
![Page 11: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/11.jpg)
Specification anti-patterns
Over-specification Hand-offs
Speci-fiction
![Page 12: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/12.jpg)
Specification anti-patterns
Over-specification Hand-offs
Under-documentationSpeci-fiction
![Page 13: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/13.jpg)
Specifica.on is
1. a document
2. which contains requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
![Page 14: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/14.jpg)
Specifica.on is
1. a document communication process
2. which contains requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
![Page 15: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/15.jpg)
Specifica.on is
1. a document communication process
2. which contains requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
“Organiza2ons which design systems are constrained to
produce designs which are copies of the communica2on
structures of these organiza2ons.”
—Melvin Conway
![Page 16: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/16.jpg)
Specifica.on is
1. a document communication process
2. which contains requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
![Page 17: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/17.jpg)
Specifica.on is
1. a document communication process
2. which contains evolves requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
![Page 18: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/18.jpg)
Specifica.on is
1. a document communication process
2. which contains requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
“A complex system that works is invariably found to have
evolved from a simple system that worked. A complex system
designed from scratch never works and cannot be patched up
to make it work. You have to start over with a working simple
system.”
—John Gall
![Page 19: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/19.jpg)
Specifica.on is
1. a document communication process
2. which contains evolves requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
![Page 20: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/20.jpg)
Specifica.on is
1. a document communication process
2. which contains evolves requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly after production release
![Page 21: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/21.jpg)
Specifica.on is
1. a document communication process
2. which contains evolves requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly and continues after production release
![Page 22: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/22.jpg)
Specifica.on is
1. a document communication process
2. which contains evolves requirements
3. and so is created as a result of the analysis phase
4. only to expire quickly and continues after production release
5. with short, concrete, and easy to maintain documentation
![Page 23: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/23.jpg)
Meet Specifica.on by Example and Gherkin
![Page 24: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/24.jpg)
Meet Specifica.on by Example and Gherkin
Having conversations about
requirements
![Page 25: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/25.jpg)
Meet Specifica.on by Example and Gherkin
Having conversations about
requirements
Writing acceptance tests for
requirements
![Page 26: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/26.jpg)
Having conversations about
requirements
Capturing conversations in
Gherkin
Writing acceptance tests for
requirements
Meet Specifica.on by Example and Gherkin
![Page 27: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/27.jpg)
Given Mike, a member of our team
And that it isn't 2 PM yet
When Mike chooses 2 PM as a start time for his meeting
Then he should be able to save his meeting
Capturing conversations in Gherkin
Gherkin specifications are written through scenarios. Analysts, designers,
programmers, and testers can all write the scenarios.
![Page 28: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/28.jpg)
Given(/^Mike, a member of our team$/) do
@mike = User.new
@mike.save(name: "Mike")
end
Given(/^that it isn't (\d+) PM yet$/) do |arg1|
# We subtract 1 from arg1 because we need to make sure
# that time is frozen before arg1
Timecop.freeze Time.parse("January 1st, 2016 #{arg1.to_i - 1} PM")
end
When(/^Mike chooses (\d+) PM as a start time for his meeting$/) do |arg1|
time = Time.parse("January 1st, 2016 #{arg1} PM")
@meeting = Meeting.new
@meeting.save(start_time: time)
@mike.meetings << @meeting
end
Then(/^he should be able to save his meeting$/) do
expect(@mike.meetings.first.saved?).to eq true
end
Gherkin scenarios can even be
automated by developers and
testers.
Automated acceptance tests make
sure that the specs stay up to date.
![Page 29: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/29.jpg)
Ability: Screening tenant leads
SCREENING is the process of evaluating a tenant lead before
signing a lease in order to choose the best candidate.
A TENANT LEAD is a potential tenant who applied to live in
an apartment managed by our rental platform.
Scenario Outline: Screening leads based on credit score
TENANTS PIPELINE is a list of verified tenant
leads a landlord can choose from.
Given a tenant lead:
| name | credit used | total debt |
| Simona Jenkins | <used> | <debt> |
And that the lead waits in the queue to the tenants pipeline
When the tenant lead has a <score>
Then we should <result> the lead to the tenants pipeline
Examples:
| used | debt | score | result |
| 40% | $202,704 | credit score of 499 | reject |
| 41% | $202,704 | credit score of 500 | accept |
Some Gherkin specifications can be
quite complex and use tables or
dynamic attributes.
![Page 30: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/30.jpg)
Ability: Screening tenant leads
SCREENING is the process of evaluating a tenant lead before
signing a lease in order to choose the best candidate.
[...]
Func.onal requirements
![Page 31: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/31.jpg)
Business Need: Security
Scenario: Activating two-factor authentication
[...]
Non-func.onal requirements
![Page 32: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/32.jpg)
The specification suite creates
an up-to-date map of
requirements.
![Page 33: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/33.jpg)
Long-term benefits
1. Better requirements
2. Less rework
3. Business-readable acceptance tests
4. Living documentation
![Page 34: Specifications for the real world — Using Specification by Example and Gherkin](https://reader031.vdocument.in/reader031/viewer/2022021919/587707331a28ab890e8b5967/html5/thumbnails/34.jpg)
“Writing Great Specifications” Using Specification by Example and Gherkin by Kamil Nicieja
Use code nicebamu to get a 39% discount on manning.com