SlideShare uma empresa Scribd logo
1 de 57
Executable specifications in action
            Building mobile bank
                   Vagif Abilov, Miles AS
About myself


   Mail: vagif.abilov@gmail.com
   Twitter: @ooobject
   GitHub: object
   BitBucket: object
   Blog:
    http://bloggingabout.net/blogs/vagif/default.aspx
   Articles: http://www.codeproject.com
I showed this screenshot in 2009…
BDD is more than «TDD done right»
   Developing features that truly add business value
   Preventing defects rather than finding defects
   Bring QA involvement to the forefront
   Define executable, verifiable and unambiguous
    requirements
   Provide a better definition of “DONE” for agile
    development

Neel Lakshminarayan’s blog
http://neelnarayan.blogspot.com/2010/07/bdd-is-more-
than-tdd-done-right.html
BDD cycle (from RSpec book)
1. Focus on one scenario
2. Write failing step definition
      drop down to component code
      3. Write failing example
      4. Get the example to pass
      5. Refactor
      repeat 3-5 until step is passing
6. Refactor
repeat 2-7 until scenario is passing
repeat 1-7 when scenario is passing
Combining BDD and TDD

                  Failing step




       Refactor                  Passing step
Cucumber and Gherkin
   Cucumber
    (https://github.com/aslakhellesoy/cucumber)
   Gherkin (https://github.com/aslakhellesoy/gherkin)



Cucumber is a BDD testing framework written in Ruby.
When using Cucumber you describe your features in
English (or the language of your choice). Cucumber
will parse the feature and generate test templates
(a.k.a. step definitions) that the developer will be
completing.
Cucumber language grammar is called Gherkin.
Gherkin language
Feature: Serve coffee
 In order to earn money
 Customers should be able to
 buy coffee at all times

 Scenario: Buy last coffee
  Given there are 1 coffees left in the machine
  And I have deposited 1$
  When I press the coffee button
  Then I should be served a coffee
Язык Геркин
Функционал: Продажа кофе
 Чтобы заработать
 Заказчики должен иметь возможность
 купить в любой момент кофе

 Сценарий: Купить последнюю чашку кофе
  Пусть в кофейном автомате есть кофе на 1 чашку
  И я опущу 1 рубль
  Когда я нажму кнопку выдачи кофе
  Тогда я должен получить чашку кофе
Language definition

<Language englishName="Norwegian" defaultSpecificCulture="nb-NO"
cultureInfo="no" code="no">
         <Feature>Egenskap</Feature>
         <Background>Bakgrunn</Background>
         <Scenario>Scenario</Scenario>
         <ScenarioOutline>Scenariomal</ScenarioOutline>
         <ScenarioOutline>Abstrakt Scenario</ScenarioOutline>
         <Examples>Eksempler</Examples>
         <Given>Gitt</Given>
         <When>Når</When>
         <Then>Så</Then>
         <And>Og</And>
         <But>Men</But>
</Language>
Advantages of writing specifications in
Gherkin

   Understandable across the team
   Focused on features
   Not coupled to framework API (less brittle)
   Not dependent on programming languages or
    platforms
   Can be maintained in different human languages
   Enables feature progress tracking, not just API
    implementation failures
Some books and articles before we move to
.NET and Visual Studio

   Dan North. «Introducing BDD»
   Gojko Adzic. «Bridging the Communication Gap»
   Gojko Adzic. «Specification by Example»
   David de Florinier et al. «The Secret Ninja Cucumber
    Scrolls» a.k.a. Cuke4Ninja.
   David Chelimsky et al. «The RSpec Book: Behaviour
    Driven Development with Rspec, Cucumber, and
    Friends»
   Steve Freeman, Nat Pryce. «Growing Object-
    Oriented Software, Guided by Tests»
So how we bring executable specifications to
Visual Studio ecosystem?
   Cuke4Nuke (discontinued last week in favour of
    SpecFlow)
    •   https://github.com/richardlawrence/Cuke4Nuke
    •   Requires Cucumber
    •   Requires Ruby
   SpecFlow
    •   https://github.com/techtalk/SpecFlow
    •   Implements Gherkin but does not require Cucumber
    •   Installed as an add-in to Visual Studio 2008/2010
    •   Supports NUnit, MSTest, xUnit.Net, MbUnit
    •   Intellisense support in Gherkin
Practice




    Building executable specifications and
   implementing features of a mobile bank

        Source code for this workshop:
   https://github.com/object/InMemoryBank
Feature: SMS payments

   In order to instantly make money transfers
   As a mobile bank user
   I want to use SMS to send money to other users
Scenarios

   Send money between two registered users
   Send money from unregistered user
   Send money to unregistered user
   Insufficient balance
Sensing mobile bank



               SMS
      Push
                In

                     We don’t want to know


               SMS
     Inspect
               Out
Common for all scenarios

   Set up the execution context by ensuring certain
    bank users are registered or unregistered (“Given”)
   Perform a command by sending an SMS message to
    the mobile bank (“When”)
   Validate that the mobile bank responds with the
    expected SMS messages (“Then”)
0. The scope is defined


   A


   B



   C



   D
1. Defining scenario steps

   Define Given/When/Then steps for each scenario
   Try to make steps reusable so once they are
    implemented they can be applied to different
    scenarios
   Organize steps by domain concept
   Feature-coupled steps are considered anti-patterns
   Conjunction steps are considered anti-patterns
1. Scenario steps are defined


       a b
   A
       c d

       d a b
   B   c d


       f   b
   C
       c d

       f   g
   D   b c
Generating feature completion report

   "%ProgramFiles(x86)%NUnit 2.5.10binnet-
    2.0nunit-console.exe" %1

   "%ProgramFiles(x86)%TechTalkSpecFlowSpecFlo
    w.exe" nunitexecutionreport %2 /xmlTestResult:%3
    /out:TestResult.html
1. Feature completion report
2. Choose first scenario to implement

   Send money between two registered users
   Send money from unregistered user
   Send money to unregistered user
   Insufficient balance
2. Start implementing steps

(a) Given user with phone number 92748326 is not
registered
(b) When user sends SMS
Phone number | Message |
| 92748326 | PAY 10 95473893 |
(c) Then following SMS should be sent
| Phone number | Message |
| 92748326 | In order to use InMemory Bank you need
to register. Command is cancelled. |
(d) And no SMS should be sent to 95473893
2. Failed step definition that requires
jumping into an inner circle


        a b                        a
    A                                  b
        c d
                                           c
        e a b
    B   c d


        f   b
    C
        c d

        f   g
    D   b c
2. Feature completion report
3. Write first failed implementation test


       a b                      a
   A                                b
       c d                 1
                                        c
       e a b
   B   c d


       f   b
   C
       c d

       f   g
   D   b c
3. Feature completion report
4. Make failed test pass

   Within the inner circle we apply TDD as we are used
    to
   Red – green – refactor
   Focus on making failing feature pass – and nothing
    more!
4. First passed implementation test


       a b                    a
   A                              b
       c d               1
                                      c
       e a b
   B   c d


       f   b
   C
       c d

       f   g
   D   b c
4. Feature completion report
5. Implementation refactoring

   We started with all-in-one MessageProcessor
   It gave us a quick kick-start and let us better
    understand how we want to partition our system
   Now we can recall Single Responsibility Principle
    and split it into more granular components
       SmsGateway
       SmsParser
       PaymentCommand
       CommandProcessor
5. Implementation refactoring


       a b                      a
   A                                b
       c d               1
                                        c
       e a b
   B   c d


       f   b
   C
       c d

       f   g
   D   b c
5. Feature completion report
6. Adding implementation tests until the
failing step passes


       a b                          a
   A                                    b
       c d                  1
                                            c
                                2
       e a b
   B   c d


       f   b
   C
       c d

       f   g
   D   b c
6. Feature completion report
7. At last first passed scenario


       a b                         a
   A                                   b
       c d                 1
                                           c
                               2
       e a b                                   d
   B   c d


       f   b
   C
       c d

       f   g
   D   b c
7. Feature completion report
8. Moving to the next scenario


       a b                        a
   A                                  b
       c d                1
                                          c
                              2
       e a b                                  d
   B   c d                                    e


       f   b
   C
       c d

       f   g
   D   b c
8. Feature completion report
9. Adding failed implementation test


       a b                           a
   A                                     b
       c d               1
                                             c
                             2
       e a b                                     d
   B   c d                       3               e


       f   b
   C
       c d

       f   g
   D   b c
9. Feature completion report
10. Making second scenario pass


       a b                              a
   A                                        b
       c d              1
                                                c
                            2
       e a b                                        d
   B   c d                      3                   e


       f   b
                                    4
   C
       c d
                                5
       f   g
   D   b c
10. Feature completion report
11. More implemented steps,
more failed scenarios


       a b                                a
   A                                          b
       c d                1
                                                  c
                              2
       e a b                                          d
   B   c d                        3                   e
                                                          f
       f   b
                                      4
   C                                                  g
       c d
                                  5
       f   g
   D   b c
11. Feature completion report
12. Adding failed implementation test


       a b                               a
   A                                         b
       c d               1
                                                 c
                             2
       e a b                                         d
   B   c d                       3                   e
                                                         f
       f   b
                                     4
   C                                                 g
       c d
                                 5
       f   g                 6
   D   b c
12. Feature completion report
13. Making third scenario pass


       a b                                a
   A                                          b
       c d                1
                                                  c
                              2
       e a b                                          d
   B   c d                        3                   e
                                                          f
       f   b
                                      4
   C                                                  g
       c d
                                  5
       f   g                  6
   D   b c                7
                      8
13. Feature completion report
14. More failed implementation tests


       a b                                  a
   A                                            b
       c d                  1
                                                    c
                                2
       e a b                                            d
   B   c d                          3                   e
                                                            f
       f   b
                                        4
   C                                                    g
       c d
                                    5
       f   g                    6
   D   b c                  7
                    9   8
14. Feature completion report
15. The feature is complete!


       a b                                    a
   A                                              b
       c d                    1
                                                      c
                                  2
       e a b                                              d
   B   c d                            3                   e
                                                              f
       f   b
                                          4
   C                                                      g
       c d
                                      5
       f   g                      6
   D              0
       b c            9       7
                          8
15. Feature completion report
Final thoughts

   Writing specifications in executable format make
    them live
   Executable specification is a living documentation
   Specifications are the result of a communication that
    includes various project members
   Easy to track progress – some teams say they even
    don’t need burndown charts anymore
   Write code outside in: start from features and
    scenarios
   Unit and integration tests are still there
Executable specifications in action




              Thank you!

Mais conteúdo relacionado

Destaque

Executable Specifications Agile Palooza
Executable Specifications Agile PaloozaExecutable Specifications Agile Palooza
Executable Specifications Agile PaloozaChris Sterling
 
Relations as Executable Specifications
Relations as Executable SpecificationsRelations as Executable Specifications
Relations as Executable SpecificationsNuno Macedo
 
Unit testing with Easymock
Unit testing with EasymockUnit testing with Easymock
Unit testing with EasymockÜrgo Ringo
 
Executable specifiaction
Executable specifiactionExecutable specifiaction
Executable specifiactionÜrgo Ringo
 
#LFMF: Tales of Test Automation Gone Wrong
#LFMF: Tales of Test Automation Gone Wrong #LFMF: Tales of Test Automation Gone Wrong
#LFMF: Tales of Test Automation Gone Wrong Elisabeth Hendrickson
 
Effective Specification Writing
Effective Specification WritingEffective Specification Writing
Effective Specification WritingDr Gordon Murray
 
8 Characteristics of good user requirements
8 Characteristics of good user requirements8 Characteristics of good user requirements
8 Characteristics of good user requirementsguest24d72f
 

Destaque (11)

Executable Specifications Agile Palooza
Executable Specifications Agile PaloozaExecutable Specifications Agile Palooza
Executable Specifications Agile Palooza
 
Relations as Executable Specifications
Relations as Executable SpecificationsRelations as Executable Specifications
Relations as Executable Specifications
 
Unit testing with Easymock
Unit testing with EasymockUnit testing with Easymock
Unit testing with Easymock
 
Executable specifiaction
Executable specifiactionExecutable specifiaction
Executable specifiaction
 
AGILEEE Friday 17:15 Talk
AGILEEE Friday 17:15 TalkAGILEEE Friday 17:15 Talk
AGILEEE Friday 17:15 Talk
 
Agile: Get Real
Agile: Get RealAgile: Get Real
Agile: Get Real
 
#LFMF: Tales of Test Automation Gone Wrong
#LFMF: Tales of Test Automation Gone Wrong #LFMF: Tales of Test Automation Gone Wrong
#LFMF: Tales of Test Automation Gone Wrong
 
Effective Specification Writing
Effective Specification WritingEffective Specification Writing
Effective Specification Writing
 
8 Characteristics of good user requirements
8 Characteristics of good user requirements8 Characteristics of good user requirements
8 Characteristics of good user requirements
 
SPECIFICATIONS
SPECIFICATIONSSPECIFICATIONS
SPECIFICATIONS
 
RSpec 2 Best practices
RSpec 2 Best practicesRSpec 2 Best practices
RSpec 2 Best practices
 

Semelhante a Executable Specifications in Action

5_Analy gf gafg f ad a ffg fa sis_for_LXS2C.docx
5_Analy  gf gafg f ad   a  ffg fa sis_for_LXS2C.docx5_Analy  gf gafg f ad   a  ffg fa sis_for_LXS2C.docx
5_Analy gf gafg f ad a ffg fa sis_for_LXS2C.docxMisael Rodriguez
 
What is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionWhat is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionIgalia
 
Pma individual assignment ii
Pma  individual assignment iiPma  individual assignment ii
Pma individual assignment iichandraswami
 
Developer Android Tools
Developer Android ToolsDeveloper Android Tools
Developer Android ToolsMacha DA COSTA
 
Senior Project Presentation
Senior Project PresentationSenior Project Presentation
Senior Project PresentationTim Heath
 
Yaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluationYaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluationAbhishek Gautam
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 
給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version)
給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version) 給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version)
給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version) William Yeh
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) Johnny Sung
 
Chapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdf
Chapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdfChapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdf
Chapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdfakknit
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentPapp Laszlo
 
Perf test Eng interview preparation
Perf test Eng interview preparationPerf test Eng interview preparation
Perf test Eng interview preparationpratik mohite
 
GCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdf
GCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdfGCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdf
GCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdfssuserc36624
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?Pin-Ying Tu
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by ExampleNalin Goonawardana
 

Semelhante a Executable Specifications in Action (20)

5_Analy gf gafg f ad a ffg fa sis_for_LXS2C.docx
5_Analy  gf gafg f ad   a  ffg fa sis_for_LXS2C.docx5_Analy  gf gafg f ad   a  ffg fa sis_for_LXS2C.docx
5_Analy gf gafg f ad a ffg fa sis_for_LXS2C.docx
 
What is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionWhat is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 edition
 
Pma individual assignment ii
Pma  individual assignment iiPma  individual assignment ii
Pma individual assignment ii
 
Developer Android Tools
Developer Android ToolsDeveloper Android Tools
Developer Android Tools
 
Senior Project Presentation
Senior Project PresentationSenior Project Presentation
Senior Project Presentation
 
Yaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluationYaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluation
 
Network analysis & cpm
Network analysis & cpmNetwork analysis & cpm
Network analysis & cpm
 
Kalyani_3+wlan_resume(1)
Kalyani_3+wlan_resume(1)Kalyani_3+wlan_resume(1)
Kalyani_3+wlan_resume(1)
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version)
給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version) 給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version)
給 RD 的 Kubernetes 初體驗 (GDG Cloud KH 2019-08 version)
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
 
Chapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdf
Chapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdfChapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdf
Chapter 1 Introduction to Computers- Programs- and Java 1- A Java prog.pdf
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Simulado Scrum master
Simulado Scrum masterSimulado Scrum master
Simulado Scrum master
 
C++ Question
C++ QuestionC++ Question
C++ Question
 
software testing
software testingsoftware testing
software testing
 
Perf test Eng interview preparation
Perf test Eng interview preparationPerf test Eng interview preparation
Perf test Eng interview preparation
 
GCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdf
GCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdfGCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdf
GCP-Professional-Cloud-Developer-Exam-v22.2.1_139-taqwlj.pdf
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 

Último

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Executable Specifications in Action

  • 1. Executable specifications in action Building mobile bank Vagif Abilov, Miles AS
  • 2. About myself  Mail: vagif.abilov@gmail.com  Twitter: @ooobject  GitHub: object  BitBucket: object  Blog: http://bloggingabout.net/blogs/vagif/default.aspx  Articles: http://www.codeproject.com
  • 3. I showed this screenshot in 2009…
  • 4. BDD is more than «TDD done right»  Developing features that truly add business value  Preventing defects rather than finding defects  Bring QA involvement to the forefront  Define executable, verifiable and unambiguous requirements  Provide a better definition of “DONE” for agile development Neel Lakshminarayan’s blog http://neelnarayan.blogspot.com/2010/07/bdd-is-more- than-tdd-done-right.html
  • 5. BDD cycle (from RSpec book) 1. Focus on one scenario 2. Write failing step definition drop down to component code 3. Write failing example 4. Get the example to pass 5. Refactor repeat 3-5 until step is passing 6. Refactor repeat 2-7 until scenario is passing repeat 1-7 when scenario is passing
  • 6. Combining BDD and TDD Failing step Refactor Passing step
  • 7. Cucumber and Gherkin  Cucumber (https://github.com/aslakhellesoy/cucumber)  Gherkin (https://github.com/aslakhellesoy/gherkin) Cucumber is a BDD testing framework written in Ruby. When using Cucumber you describe your features in English (or the language of your choice). Cucumber will parse the feature and generate test templates (a.k.a. step definitions) that the developer will be completing. Cucumber language grammar is called Gherkin.
  • 8. Gherkin language Feature: Serve coffee In order to earn money Customers should be able to buy coffee at all times Scenario: Buy last coffee Given there are 1 coffees left in the machine And I have deposited 1$ When I press the coffee button Then I should be served a coffee
  • 9. Язык Геркин Функционал: Продажа кофе Чтобы заработать Заказчики должен иметь возможность купить в любой момент кофе Сценарий: Купить последнюю чашку кофе Пусть в кофейном автомате есть кофе на 1 чашку И я опущу 1 рубль Когда я нажму кнопку выдачи кофе Тогда я должен получить чашку кофе
  • 10. Language definition <Language englishName="Norwegian" defaultSpecificCulture="nb-NO" cultureInfo="no" code="no"> <Feature>Egenskap</Feature> <Background>Bakgrunn</Background> <Scenario>Scenario</Scenario> <ScenarioOutline>Scenariomal</ScenarioOutline> <ScenarioOutline>Abstrakt Scenario</ScenarioOutline> <Examples>Eksempler</Examples> <Given>Gitt</Given> <When>Når</When> <Then>Så</Then> <And>Og</And> <But>Men</But> </Language>
  • 11. Advantages of writing specifications in Gherkin  Understandable across the team  Focused on features  Not coupled to framework API (less brittle)  Not dependent on programming languages or platforms  Can be maintained in different human languages  Enables feature progress tracking, not just API implementation failures
  • 12. Some books and articles before we move to .NET and Visual Studio  Dan North. «Introducing BDD»  Gojko Adzic. «Bridging the Communication Gap»  Gojko Adzic. «Specification by Example»  David de Florinier et al. «The Secret Ninja Cucumber Scrolls» a.k.a. Cuke4Ninja.  David Chelimsky et al. «The RSpec Book: Behaviour Driven Development with Rspec, Cucumber, and Friends»  Steve Freeman, Nat Pryce. «Growing Object- Oriented Software, Guided by Tests»
  • 13. So how we bring executable specifications to Visual Studio ecosystem?  Cuke4Nuke (discontinued last week in favour of SpecFlow) • https://github.com/richardlawrence/Cuke4Nuke • Requires Cucumber • Requires Ruby  SpecFlow • https://github.com/techtalk/SpecFlow • Implements Gherkin but does not require Cucumber • Installed as an add-in to Visual Studio 2008/2010 • Supports NUnit, MSTest, xUnit.Net, MbUnit • Intellisense support in Gherkin
  • 14. Practice Building executable specifications and implementing features of a mobile bank Source code for this workshop: https://github.com/object/InMemoryBank
  • 15. Feature: SMS payments  In order to instantly make money transfers  As a mobile bank user  I want to use SMS to send money to other users
  • 16. Scenarios  Send money between two registered users  Send money from unregistered user  Send money to unregistered user  Insufficient balance
  • 17. Sensing mobile bank SMS Push In We don’t want to know SMS Inspect Out
  • 18. Common for all scenarios  Set up the execution context by ensuring certain bank users are registered or unregistered (“Given”)  Perform a command by sending an SMS message to the mobile bank (“When”)  Validate that the mobile bank responds with the expected SMS messages (“Then”)
  • 19. 0. The scope is defined A B C D
  • 20. 1. Defining scenario steps  Define Given/When/Then steps for each scenario  Try to make steps reusable so once they are implemented they can be applied to different scenarios  Organize steps by domain concept  Feature-coupled steps are considered anti-patterns  Conjunction steps are considered anti-patterns
  • 21. 1. Scenario steps are defined a b A c d d a b B c d f b C c d f g D b c
  • 22. Generating feature completion report  "%ProgramFiles(x86)%NUnit 2.5.10binnet- 2.0nunit-console.exe" %1  "%ProgramFiles(x86)%TechTalkSpecFlowSpecFlo w.exe" nunitexecutionreport %2 /xmlTestResult:%3 /out:TestResult.html
  • 24. 2. Choose first scenario to implement  Send money between two registered users  Send money from unregistered user  Send money to unregistered user  Insufficient balance
  • 25. 2. Start implementing steps (a) Given user with phone number 92748326 is not registered (b) When user sends SMS Phone number | Message | | 92748326 | PAY 10 95473893 | (c) Then following SMS should be sent | Phone number | Message | | 92748326 | In order to use InMemory Bank you need to register. Command is cancelled. | (d) And no SMS should be sent to 95473893
  • 26. 2. Failed step definition that requires jumping into an inner circle a b a A b c d c e a b B c d f b C c d f g D b c
  • 28. 3. Write first failed implementation test a b a A b c d 1 c e a b B c d f b C c d f g D b c
  • 30. 4. Make failed test pass  Within the inner circle we apply TDD as we are used to  Red – green – refactor  Focus on making failing feature pass – and nothing more!
  • 31. 4. First passed implementation test a b a A b c d 1 c e a b B c d f b C c d f g D b c
  • 33. 5. Implementation refactoring  We started with all-in-one MessageProcessor  It gave us a quick kick-start and let us better understand how we want to partition our system  Now we can recall Single Responsibility Principle and split it into more granular components  SmsGateway  SmsParser  PaymentCommand  CommandProcessor
  • 34. 5. Implementation refactoring a b a A b c d 1 c e a b B c d f b C c d f g D b c
  • 36. 6. Adding implementation tests until the failing step passes a b a A b c d 1 c 2 e a b B c d f b C c d f g D b c
  • 38. 7. At last first passed scenario a b a A b c d 1 c 2 e a b d B c d f b C c d f g D b c
  • 40. 8. Moving to the next scenario a b a A b c d 1 c 2 e a b d B c d e f b C c d f g D b c
  • 42. 9. Adding failed implementation test a b a A b c d 1 c 2 e a b d B c d 3 e f b C c d f g D b c
  • 44. 10. Making second scenario pass a b a A b c d 1 c 2 e a b d B c d 3 e f b 4 C c d 5 f g D b c
  • 46. 11. More implemented steps, more failed scenarios a b a A b c d 1 c 2 e a b d B c d 3 e f f b 4 C g c d 5 f g D b c
  • 48. 12. Adding failed implementation test a b a A b c d 1 c 2 e a b d B c d 3 e f f b 4 C g c d 5 f g 6 D b c
  • 50. 13. Making third scenario pass a b a A b c d 1 c 2 e a b d B c d 3 e f f b 4 C g c d 5 f g 6 D b c 7 8
  • 52. 14. More failed implementation tests a b a A b c d 1 c 2 e a b d B c d 3 e f f b 4 C g c d 5 f g 6 D b c 7 9 8
  • 54. 15. The feature is complete! a b a A b c d 1 c 2 e a b d B c d 3 e f f b 4 C g c d 5 f g 6 D 0 b c 9 7 8
  • 56. Final thoughts  Writing specifications in executable format make them live  Executable specification is a living documentation  Specifications are the result of a communication that includes various project members  Easy to track progress – some teams say they even don’t need burndown charts anymore  Write code outside in: start from features and scenarios  Unit and integration tests are still there
  • 57. Executable specifications in action Thank you!