SlideShare a Scribd company logo
1 of 20
Presented by : Ben Wafi Oussama
                                  1
PLAN
•   1 Introduction
•   2 Defintion
•   3 Gherkin
•   4 Gherkin Source File
•   5 Cucumber & BDD
•   6-Installation
•   7-Running
•   8-Demo
•   9-Conclusion

                              2
Introduction(1/2)
• Cucumber lets software development teams
  describe how software should behave in plain
  text. The text is written in a business readable
  domain specific-language and serves as
  documentation, automated tests and
  development-aid - all rolled into one format.
• Cucumber works with Ruby, Java, .NET, Flex or
  web applications written in any language. It has
  been translated to over 40 spoken languages.

                                                     3
Introduction(2/2)
1: Describe behavior in plain text     2: Write a step definition in Ruby     3: Run and watch it fail




 4. Write code to make the step pass   5. Run again and see the step pass   6. Repeat 2-5 until green like a cuke




                                                                                                             4
Definition
• Cucumber is a tool that executes plain-text
  functional descriptions as automated tests.
  The language that Cucumber understands is
  called Gherkin
         It is a Business Readable, Domain Specific
         Language that lets you describe software’s
             behavior without detailing how that
                   behavior is implemented.


                                                      5
Definition
• Cucumber itself is written in Ruby, but it can
  be used to “test” code written in Ruby or
  other languages including but not limited to
  Java, C# and Python.




                                                   6
Gherkin(1/3)
• Gherkin serves two purposes –
  documentation and automated tests
• Gherkin’s grammar is defined in the Treetop
  grammar that is part of the Cucumber
  codebase. The grammar exists in different
  flavors for many spoken languages (37 at the
  time of writing), so that your team can use the
  keywords in your own language.
• Source files have .feature extension.

                                                7
Gherkin Syntax(2/3)
• Like Python and YAML, Gherkin is a line-
  oriented language that uses indentation to
  define structure. Line endings terminate
  statements (eg, steps).
• Parser divides the input into
  features, scenarios and steps. When you run
  the feature the trailing portion (after the
  keyword) of each step is matched to a Ruby
  code block called Step Definitions.

                                                8
Gherkin Syntax(3/3)
•   "en": {                                      •   "ar": {
•   "name": "English",                           •   "name": "Arabic",
•   "native": "English",                         •   "native": "
•   "feature": "Feature|Busines Need|Ability",   •    feature": "
•   "background": "Background",                  •    background": "
•   "scenario": "Scenario",                      •    scenario": "
•   "scenariooutline":"ScenariOutline|Scenar     •    scenario_outline": "
•   "examples": "Examples|Scenarios",            •    examples": "
•   "given": "*|Given",                          •    given": "*|
•   "when": "*|When",                            •    when": "*|
•   "then": "*|Then",                            •    then": "*|
•   "and": "*|And",                              •    and": "*|
•   "but": "*|But"                               •    but": "*|
•   },                                           •




                                                                             9
A Gherkin source file usually looks like this
1:    Feature: Some terse yet descriptive text of what is desired
2:             In order to realize a named business value
3:             As an explicit system actor
4:    I want to gain some beneficial outcome which furthers the goal
5:
6:    Scenario: Some determinable business situation
7:            Given some precondition
8:            And some other precondition
9:            When some action by the actor
10:           And some other action
11:           And yet another action
12:           Then some testable outcome is achieved
13:           And something else we can check happens too
14:
15:   Scenario: A different situation



                                                                       10
• First line starts the feature.
• Lines 2-4 are unparsed text, which is expected
  to describe the business value of this feature.
  Line 6 starts a scenario.
• Lines 7-13 are the steps for the scenario.
• Line 15 starts next scenario and so on.



                                                11
.Feature
• The scenario is then divided into three parts.
1. The ‘Given’ part describes how the system
   should be prepared before the testing. This is
   the setup for the system.
2. The ‘When’ part describes how the system
   should be used. This is the execution part of the
   example.
3. The ‘Then’ part is where you verify that the
   system is in the expected state. This is the assert
   part of the test.
                                                     12
TDD & BDD
• Test driven development
The word “driven” here refers to the way of writing the
tests first, then the code to make the tests pass. Test
driven development is more of a developer oriented
approach, a more low level way of doing things.
• Behaviour driven development
In BDD on the other hand, the tests are described in a
natural language, which makes the tests more accessible
to people outside of development or testing teams. It can
describe the functionality as specifications do.


                                                        13
Cucumber and BDD
• While Cucumber can be thought of as a
  “testing” tool, the intent of the tool is to
  support BDD. This means that the “tests”
  (plain text feature descriptions with scenarios)
  are typically written before anything else and
  verified by business analysts, domain
  experts, etc. non technical stakeholders. The
  production code is then written outside-in, to
  make the stories pass.
                                                 14
Installation(1/2)
• In order to use Cucumber within some
  frameworks or specific environments :

• install for Ruby on Rails
• install for Jruby and Java
• install for IronRuby and .NET



                                          15
Installation(2/2)
                              Cucumber-jvm
 JUnit class that will connect the feature to a runner,
                                                          Cucumber-html.jar
    Jchronic.jar



Cucumber-core.jar                                            Cucumber-java.jar



                            Cucumber-junit.jar
                                                                          16
Running Cucumber
• There are quite a few ways you can run
  Cucumber. It depends on what programming
  language you are using and also what build tool
  you are using (if any).
• Command Line
• Rake
• Maven
• Ant
• JUnit
• IDEs (Eclipse, IDEA)

                                                    17
Demo
                          Application




Src/test/java                                        Src/main/java




     HelloSteps.Defjava

     RunCukesTest.java

                                        Hello.java     .features

                                                              18
Conclusion

Try to use Cucumber




                      19
Thank You




            20

More Related Content

What's hot

Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkinArati Joshi
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD123abcda
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Mindfire Solutions
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumberDaniel Kummer
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber Knoldus Inc.
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentationAkhila B
 
Introduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaIntroduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaSeb Rose
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)Rohit Bisht
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDDKnoldus Inc.
 
An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)Suman Guha
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testingdversaci
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberKMS Technology
 
Cypress - Best Practices
Cypress - Best PracticesCypress - Best Practices
Cypress - Best PracticesBrian Mann
 

What's hot (20)

Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkin
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumber
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
Cucumber Tool
Cucumber ToolCucumber Tool
Cucumber Tool
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber
 
Cucumber_Training_ForQA
Cucumber_Training_ForQACucumber_Training_ForQA
Cucumber_Training_ForQA
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentation
 
BDD & Cucumber
BDD & CucumberBDD & Cucumber
BDD & Cucumber
 
Introduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaIntroduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for Java
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDD
 
An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testing
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
Bdd Introduction
Bdd IntroductionBdd Introduction
Bdd Introduction
 
Cypress - Best Practices
Cypress - Best PracticesCypress - Best Practices
Cypress - Best Practices
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 

Similar to Cucumber presenation

Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
Behavior driven development
Behavior driven developmentBehavior driven development
Behavior driven developmentExtremia
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript ProgrammingYoshiki Shibukawa
 
Chapter-1 Introduction.pptx
Chapter-1 Introduction.pptxChapter-1 Introduction.pptx
Chapter-1 Introduction.pptxSumanBhandari40
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityGeoff Harcourt
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaattiqrocket
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadSoftware Guru
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189Mahmoud Samir Fayed
 
Writing Well-Behaved Unix Utilities
Writing Well-Behaved Unix UtilitiesWriting Well-Behaved Unix Utilities
Writing Well-Behaved Unix UtilitiesRob Miller
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
 
1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptxBhargaviDalal3
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Brian Sam-Bodden
 
Cucumber With Selenium
Cucumber With SeleniumCucumber With Selenium
Cucumber With SeleniumVishwanath KC
 
Behavior Driven Development - TdT@Cluj #15
Behavior Driven Development - TdT@Cluj #15Behavior Driven Development - TdT@Cluj #15
Behavior Driven Development - TdT@Cluj #15Tabăra de Testare
 

Similar to Cucumber presenation (20)

Cucumber in Practice(en)
Cucumber in Practice(en)Cucumber in Practice(en)
Cucumber in Practice(en)
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
Behavior driven development
Behavior driven developmentBehavior driven development
Behavior driven development
 
Ruby with cucmber
Ruby with cucmberRuby with cucmber
Ruby with cucmber
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
 
Chapter-1 Introduction.pptx
Chapter-1 Introduction.pptxChapter-1 Introduction.pptx
Chapter-1 Introduction.pptx
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
 
Lesson1 intro
Lesson1 introLesson1 intro
Lesson1 intro
 
Lesson1 intro
Lesson1 introLesson1 intro
Lesson1 intro
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidad
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189
 
Writing Well-Behaved Unix Utilities
Writing Well-Behaved Unix UtilitiesWriting Well-Behaved Unix Utilities
Writing Well-Behaved Unix Utilities
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
 
Cucumber With Selenium
Cucumber With SeleniumCucumber With Selenium
Cucumber With Selenium
 
Behavior Driven Development - TdT@Cluj #15
Behavior Driven Development - TdT@Cluj #15Behavior Driven Development - TdT@Cluj #15
Behavior Driven Development - TdT@Cluj #15
 

Cucumber presenation

  • 1. Presented by : Ben Wafi Oussama 1
  • 2. PLAN • 1 Introduction • 2 Defintion • 3 Gherkin • 4 Gherkin Source File • 5 Cucumber & BDD • 6-Installation • 7-Running • 8-Demo • 9-Conclusion 2
  • 3. Introduction(1/2) • Cucumber lets software development teams describe how software should behave in plain text. The text is written in a business readable domain specific-language and serves as documentation, automated tests and development-aid - all rolled into one format. • Cucumber works with Ruby, Java, .NET, Flex or web applications written in any language. It has been translated to over 40 spoken languages. 3
  • 4. Introduction(2/2) 1: Describe behavior in plain text 2: Write a step definition in Ruby 3: Run and watch it fail 4. Write code to make the step pass 5. Run again and see the step pass 6. Repeat 2-5 until green like a cuke 4
  • 5. Definition • Cucumber is a tool that executes plain-text functional descriptions as automated tests. The language that Cucumber understands is called Gherkin It is a Business Readable, Domain Specific Language that lets you describe software’s behavior without detailing how that behavior is implemented. 5
  • 6. Definition • Cucumber itself is written in Ruby, but it can be used to “test” code written in Ruby or other languages including but not limited to Java, C# and Python. 6
  • 7. Gherkin(1/3) • Gherkin serves two purposes – documentation and automated tests • Gherkin’s grammar is defined in the Treetop grammar that is part of the Cucumber codebase. The grammar exists in different flavors for many spoken languages (37 at the time of writing), so that your team can use the keywords in your own language. • Source files have .feature extension. 7
  • 8. Gherkin Syntax(2/3) • Like Python and YAML, Gherkin is a line- oriented language that uses indentation to define structure. Line endings terminate statements (eg, steps). • Parser divides the input into features, scenarios and steps. When you run the feature the trailing portion (after the keyword) of each step is matched to a Ruby code block called Step Definitions. 8
  • 9. Gherkin Syntax(3/3) • "en": { • "ar": { • "name": "English", • "name": "Arabic", • "native": "English", • "native": " • "feature": "Feature|Busines Need|Ability", • feature": " • "background": "Background", • background": " • "scenario": "Scenario", • scenario": " • "scenariooutline":"ScenariOutline|Scenar • scenario_outline": " • "examples": "Examples|Scenarios", • examples": " • "given": "*|Given", • given": "*| • "when": "*|When", • when": "*| • "then": "*|Then", • then": "*| • "and": "*|And", • and": "*| • "but": "*|But" • but": "*| • }, • 9
  • 10. A Gherkin source file usually looks like this 1: Feature: Some terse yet descriptive text of what is desired 2: In order to realize a named business value 3: As an explicit system actor 4: I want to gain some beneficial outcome which furthers the goal 5: 6: Scenario: Some determinable business situation 7: Given some precondition 8: And some other precondition 9: When some action by the actor 10: And some other action 11: And yet another action 12: Then some testable outcome is achieved 13: And something else we can check happens too 14: 15: Scenario: A different situation 10
  • 11. • First line starts the feature. • Lines 2-4 are unparsed text, which is expected to describe the business value of this feature. Line 6 starts a scenario. • Lines 7-13 are the steps for the scenario. • Line 15 starts next scenario and so on. 11
  • 12. .Feature • The scenario is then divided into three parts. 1. The ‘Given’ part describes how the system should be prepared before the testing. This is the setup for the system. 2. The ‘When’ part describes how the system should be used. This is the execution part of the example. 3. The ‘Then’ part is where you verify that the system is in the expected state. This is the assert part of the test. 12
  • 13. TDD & BDD • Test driven development The word “driven” here refers to the way of writing the tests first, then the code to make the tests pass. Test driven development is more of a developer oriented approach, a more low level way of doing things. • Behaviour driven development In BDD on the other hand, the tests are described in a natural language, which makes the tests more accessible to people outside of development or testing teams. It can describe the functionality as specifications do. 13
  • 14. Cucumber and BDD • While Cucumber can be thought of as a “testing” tool, the intent of the tool is to support BDD. This means that the “tests” (plain text feature descriptions with scenarios) are typically written before anything else and verified by business analysts, domain experts, etc. non technical stakeholders. The production code is then written outside-in, to make the stories pass. 14
  • 15. Installation(1/2) • In order to use Cucumber within some frameworks or specific environments : • install for Ruby on Rails • install for Jruby and Java • install for IronRuby and .NET 15
  • 16. Installation(2/2) Cucumber-jvm JUnit class that will connect the feature to a runner, Cucumber-html.jar Jchronic.jar Cucumber-core.jar Cucumber-java.jar Cucumber-junit.jar 16
  • 17. Running Cucumber • There are quite a few ways you can run Cucumber. It depends on what programming language you are using and also what build tool you are using (if any). • Command Line • Rake • Maven • Ant • JUnit • IDEs (Eclipse, IDEA) 17
  • 18. Demo Application Src/test/java Src/main/java HelloSteps.Defjava RunCukesTest.java Hello.java .features 18
  • 19. Conclusion Try to use Cucumber 19
  • 20. Thank You 20