Specification By Example
By Example!
Gojko Adzic, “Specification By Example”, 2011
1
Specification By Example
Principles
2
Notifications help assist the business processes. For
example, to notify the Document Experts that there is a
request for ...
Build shared understanding
4
Don’t notify Notify
WTF?!
JUDGEMENT DAY
(AKA RELEASE DATE)
Specification Workshop at start of...
DELIVERED REQUIREMENT
Notifications
assist the
business
processes. For
example, to notify the
Document Experts
that there ...
Feature: Notify request for
adjudication
…
Scenario: Send notification of
suspicious document
Given I have scanned a
suspi...
Speak the business language...
7
Feature: Notify request for
adjudication
…
Scenario: Send notification of
suspicious docu...
... and be consistent...
8
Feature: Notify request for adjudication
…
Scenario: Send notification of suspicious document
G...
Specification By Example
Good Practices
9
Keep features self-contained (think classes)
10
Feature: Data Capture
…
Scenario: Capture mandatory demographic data
Scena...
Feature: …
Scenario: <statement of the functionality the scenario exercises>
[Given <application state and/or input data a...
Specifications, not clicks...
12
Feature: Demographic Capture
…
Scenario: Demographic data not mandatory
Given that Mandat...
Feature: <one-liner functionality description easy to reference >
As a <persona/role>
I want to <action/procedure>
In orde...
Focus on 1 user action per scenario
14
Feature: Save capture
…
Scenario: Mandatory modules completed
Given that all mandat...
Actions, not expected results
15
Feature: Save capture
…
Scenario: Saving fails when mandatory modules not completed
Given...
Refactor specification by abstraction...
16
Feature: Export document verification report
…
Scenario: Export false Portugue...
Same scenario, multiple examples...
17
Feature: Verify documents
…
Scenario: Verify suspicious Portuguese passport
When I ...
Specification By Example
Process
18
19
Why should you care?
Dev – earlier feedback, done = all scenarios passing
QA – know what to test, avoid long feedback l...
20
Working with features
• Shared ownership
• When writing understand what are the different functionalities covered in ex...
21
Feature organization
• Feature structure
Root folder “features”. Subfolders group related functionality.
• Feature tags...
22
Work organization
Client story Server story
23
Work organization (cont)
ApplicationLicence feature ServiceLicence feature
24
References
Basic concepts (worth reading entire chapter)
Specification By Example
Introducing BDD
Acceptance TDD (ATDD)...
Upcoming SlideShare
Loading in …5
×

Specification by Example - By Example

898 views

Published on

What is Specification By Example - principles, good practices and process

  • Be the first to comment

Specification by Example - By Example

  1. 1. Specification By Example By Example! Gojko Adzic, “Specification By Example”, 2011 1
  2. 2. Specification By Example Principles 2
  3. 3. Notifications help assist the business processes. For example, to notify the Document Experts that there is a request for adjudication to take place, or for the Document Experts to notify the relevant personnel that a new false document has been stored in the false document database. Examples, not ambiguous requirements 3 Feature: Notify request for adjudication As a verification operator I want to notify document experts of adjudication requests So that I can be informed if a document is genuine or false Scenario: Send notification of suspicious document Given I have scanned a suspicious Portuguese passport When I notify the document expert Then document expert receives email containing data | document type | | scan timestamp | | document white image | | document ultraviolet image | Scenario: Don’t notify when document is genuine
  4. 4. Build shared understanding 4 Don’t notify Notify WTF?! JUDGEMENT DAY (AKA RELEASE DATE) Specification Workshop at start of sprint/release - Testers (“what if we get a yellow check?”) - Developers (“yellow check = server is down”) - Product Owner/BA (“for me yellow check = red check”)
  5. 5. DELIVERED REQUIREMENT Notifications assist the business processes. For example, to notify the Document Experts that there is a request for adjudication to take place, or for the Document Experts to notify the relevant personnel that a new false document has been stored in the false document database. Living documentation 5 1 year later client calls… “Actually… email is déjà vu… we want Facebook posts!” Notifications help assist the business processes. For example, to notify the Document Experts that there is a request for adjudication to take place, or for the Document Experts to notify the relevant personnel that a new false document has been stored in the false document database. New release delivered…
  6. 6. Feature: Notify request for adjudication … Scenario: Send notification of suspicious document Given I have scanned a suspicious Portuguese passport When I notify the document expert Then document expert receives email containing data | document type | | scan timestamp | | document white image | | document ultraviolet image | Scenario: Don’t notify when document is genuine … DELIVERED FEATURE Living documentation (cont) 6 1 year later client calls… “Actually… email is déjà vu… we want Facebook posts!” Feature: Notify request for adjudication … Scenario: Send notification of suspicious document Given I have scanned a suspicious Portuguese passport When I notify the document expert Then document expert receives email containing data | document type | | scan timestamp | | document white image | | document ultraviolet image | Scenario: Don’t notify when document is genuine … Feature: Notify request for adjudication … Scenario: Send notification of suspicious document Given I have scanned a suspicious Portuguese passport When I notify the document expert Then document expert receives Facebook post containing data | document type | | scan timestamp | | document white image | | document ultraviolet image | Scenario: Don’t notify when document is genuine … Before implementation…
  7. 7. Speak the business language... 7 Feature: Notify request for adjudication … Scenario: Send notification of suspicious document Given I have scanned a suspicious Portuguese passport When I notify the document expert Then document expert receives Facebook post containing data | document type | | scan timestamp | | document white image | | document ultraviolet image | Feature: Notify request for adjudication … Scenario: Send notification of suspicious document Given I have scanned a suspicious Portuguese passport When I notify the document expert Then document expert receives Facebook post with text “You have a pending request” and URL to PDF report containing data | document type | | scan timestamp | | document white image | | document ultraviolet image |
  8. 8. ... and be consistent... 8 Feature: Notify request for adjudication … Scenario: Send notification of suspicious document Given I have scanned a suspicious Portuguese passport When I notify the document expert … Scenario: Send notification of suspicious driving licence Given I placed a suspicious Portuguese driving licence in the scanner When I notify the document expert … Feature: Notify request for adjudication … Scenario: Send notification of suspicious passport Given I have scanned a suspicious Portuguese passport When I notify the document expert … Scenario: Send notification of suspicious driving licence Given I have scanned a suspicious Portuguese driving licence When I notify the document expert … Note: minimize synonims, e.g. “valid” and “correct” -> pick one
  9. 9. Specification By Example Good Practices 9
  10. 10. Keep features self-contained (think classes) 10 Feature: Data Capture … Scenario: Capture mandatory demographic data Scenario: Capture one page document Scenario: Capture default fingerprints Scenario: Capture photo with valid live QA checks Scenario: Capture signature Scenario: Save when mandatory modules completed Feature: Demographic Capture … Scenario: Capture mandatory demographic data Feature: A4 Documents Capture … Scenario: Capture one page document … Note: it’s ok to have a feature with a single scenario Feature: Fingerprints Capture … Scenario: Capture default fingerprints Feature: Login … Scenario: Can't login without software licence
  11. 11. Feature: … Scenario: <statement of the functionality the scenario exercises> [Given <application state and/or input data and/or user roles>] When <user action or system event> Then <system state and/or output data> <validation check> Feature: Photo Enrollment Scenario: Can’t save enrollment when missing photo Given demographic module is complete And photo module is not complete When I save the data capture Then an error message containing “missing photo” is displayed Respect Given-When-Then mantra 11 Feature: Photo Enrollment Scenario: No photo Given I enrolled a new applicant and there is no photo When I try to save Then data is not saved
  12. 12. Specifications, not clicks... 12 Feature: Demographic Capture … Scenario: Demographic data not mandatory Given that MandatoryFields is set to FALSE in config file When I click Save button Then data is saved in the local database Feature: Demographic Capture … Scenario: Demographic data not mandatory Given demographic data is not mandatory When I save data capture Then captured data is saved offline Exception: when the client imposes technical constraints then keep them in scenario, e.g. “send data by FTP”
  13. 13. Feature: <one-liner functionality description easy to reference > As a <persona/role> I want to <action/procedure> In order to <goal> Feature: Verify documents As a verification operator I want to verify documents In order to prevent fraudulent account creation Scenario: Verify suspicious document When I scan a suspicious Portuguese passport Then a flashing red indicator is displayed Focus on 1 persona per feature 13 Feature: Verify documents As a system user I want to use the application In order to verify documents Scenario: Scan suspicious document Given I have valid operator credentials When I scan a suspicious Portuguese passport Then a flashing red indicator is displayed
  14. 14. Focus on 1 user action per scenario 14 Feature: Save capture … Scenario: Mandatory modules completed Given that all mandatory modules are completed When I save capture Then data is saved offline And is available for both Data Capture and Export services Feature: Save capture … Scenario: Mandatory modules completed before saving … Scenario: Search previously saved capture … Scenario: Export previously saved capture to filesystem … Note: user actions can be physical, e.g. “When applicant places right index finger on scanner”
  15. 15. Actions, not expected results 15 Feature: Save capture … Scenario: Saving fails when mandatory modules not completed Given that mandatory module “Demographics” is not completed When I try to save capture Then an error message containing “missing modules” is displayed Feature: Save capture … Scenario: Saving fails when mandatory modules not completed Given that mandatory module “Demographics” is not completed When I save capture Then an error message containing “missing modules” is displayed
  16. 16. Refactor specification by abstraction... 16 Feature: Export document verification report … Scenario: Export false Portuguese passport verification report Given I have scanned a suspicious Portuguese passport And I have notified the document expert And document expert confirmed document is false And I received notification When I select to export document verification report Then PDF refort is generated in “c:Program DataDocVerifierExport” Feature: Export document verification report … Scenario: Export false Portuguese passport verification report Given a confirmed false Portuguese passport When I select to export document verification report Then PDF refort is generated in “c:Program DataDocVerifierExport”
  17. 17. Same scenario, multiple examples... 17 Feature: Verify documents … Scenario: Verify suspicious Portuguese passport When I scan a suspicious Portuguese passport Then a flashing red indicator is displayed Scenario: Verify suspicious Spanish passport When I scan a suspicious Spanish passport Then a flashing red indicator is displayed Feature: Verify documents … Scenario Outline: Verify suspicious passport When I scan a suspicious <nationality> passport Then a flashing red indicator is displayed Examples: | nationality | | Portuguese | | Spanish | Note: parameters in the scenario name don’t get replaced and obscure the purpose
  18. 18. Specification By Example Process 18
  19. 19. 19 Why should you care? Dev – earlier feedback, done = all scenarios passing QA – know what to test, avoid long feedback loops at crunch time (aka release date) PO/BA – make sure team understands business needs, delivers value, not technical achievements Support – know what application is supposed to do in maintenance phase - support request or change request?
  20. 20. 20 Working with features • Shared ownership • When writing understand what are the different functionalities covered in existing features to avoid overlap. Everyone responsible to keep them tidy and consistent. • Acceptance, not unit tests • Unit tests check stuff is stored in DB, features check that data can be extracted for the user • Exception: audit data often needs to be checked directly against DB • Who can change features? Everyone in the team! • When can they be changed? Any time spec changes! Remember… Specification by Example is about improving communication, so… communicate!
  21. 21. 21 Feature organization • Feature structure Root folder “features”. Subfolders group related functionality. • Feature tags (one of each) • Functionality tag: same as parent folder name, e.g. @Authentication, @Backup, @DataExport, … • Release tag, e.g.: @prototype, @phase01, @phase02 • Testing tag: @functional, @usability, @load, @security • Comments / references • can reference sources of requirements, either word documents, email exchanges with clients, change requests, etc… • not mandatory, beware it’s hard to keep up to date
  22. 22. 22 Work organization Client story Server story
  23. 23. 23 Work organization (cont) ApplicationLicence feature ServiceLicence feature
  24. 24. 24 References Basic concepts (worth reading entire chapter) Specification By Example Introducing BDD Acceptance TDD (ATDD) Explained Specification By Example: a Love Story

×