Introduction to BEHAVIOUR DRIVEN DEVELOPMENT With Cucumber for Java 1 Reference Book: The Cucumber for Java Book Seb Rose, Matt Wynne and Aslak Hellesoy Created By Jawad Khan Sr. Automation Engineer (7+ Exp)
AGENDA » Automated Acceptance Tests? » What is TDD and What is BDD? » What is Cucumber? How it works? » Cucumber Variants » Demo Cucumber for Java 2
What is Automated Acceptance Tests? » Stakeholder and DEV team collaborate & write automated tests that express the outcome of product » Test fails at the time of writing, because no code has been written yet but capture the clear requirements » Development will continue until all cases are passed » AA tests help your team to focus and ensure the work direction 3 Page: 4
Test Driven Development (TDD) 4 The approach in TDD is “Write Test first and then development will follow the test cases for further development. inshort “Tests Drive the Development” Note: In TDD, unit test, functional test and acceptance test can be acceptable based on requirements.
How to perform TDD Test 5
BDD - Behavior Driven Development 6
BDD - Behavior Driven Development » It is a software development technique & an extension of TDD » It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. » Test cases are written in a natural language that even non- programmers can read » BDD test can be useful for Product Owner, BA, Dev and Manual/Automation QA 7
BDD Tests Benefits » Helps both Manual/Automation Testers in requirement understanding » Helps in both Manual/Automation Testing » Adaptability » Ubiquitous Language » Living Documentation » Source of Truth 8 Page: 5-7
What is Cucumber-BDD? Cucumber is a testing tool with approach which supports Behavior Driven Development (BDD). It explains the behavior of the application in a simple English text using Gherkin language. 9
How Cucumber Works 10
11
What’s Gherkin For? Gherkin is the format for cucumber specifications. It is a domain specific language which helps you to describe business behavior without the need to go into detail of implementation. 12
Format and Syntax Gherkin files use the .feature file extension. They’re saved as plain text, meaning they can be read and edited with simple tools. In this respect, Gherkin is very similar to file formats like Markdown, Textile, and YAML. 13
Keywords A Gherkin file is given its structure and meaning using a set of special key-words. » Feature » Background » Scenario » Given » When » Then » And » But » Scenario Outline » Examples 14
Cucumber Feature File Scenarios 15
Requirement Specification Documentation In Traditional Style 16 Payment application business cases
Requirement Specification Documentation In BDD Style 17
Some more scenarios 18
Some more scenarios 19
Important Things about Cucumber 20 Stateless: Each scenario must make sense and be able to be executed independently of any other scenario Comments: Spoken Languages: 70+ languages (https://bit.ly/2ANiXlt) )
Step Definitions From the Outside 21
Cucumber Working [Review] 22
Feature File & Java Class 23 » Steps and Step Definitions » Matching a Step » Creating a Step Definition
Regular Expressions in Step Def. 24 Capture Groups Alternative More RE on Page:53
Cucumber Test Results Status 25 » Failed » Pending » Undefined » Skipped » Passed Read Page:60
Expressive Scenarios
Cucumber Background 27 A background section in a feature file allows you to specify a set of steps that are common to every scenario in the file. Read Page:69
Cucumber Data Tables 28 Data tables give you a way to extend a Gherkin step beyond a single line to include a larger piece of data Read Page:74
Cucumber Scenario Outline 29 Can be use when same test case need to execute on different provided data Read Page:81
Cucumber Tags 30 Tags are the sticky notes you’ve put on pages you want to be able to find easily Read Page:88
Cucumber Hooks 31 Cucumber supports hooks, which are methods that run before or after each scenario. Read Page:156
THANKS! Any questions? You can find me at » LinkedIn: linkedin.com/in/jawadkhan92 » FB Group: facebook.com/groups/SirJawadKhan » Email: jawadkhan.tutor@gmail.com 32

Introduction to Behaviour Driven Development (BDD) and Cucumber with Java

  • 1.
    Introduction to BEHAVIOUR DRIVEN DEVELOPMENT With Cucumberfor Java 1 Reference Book: The Cucumber for Java Book Seb Rose, Matt Wynne and Aslak Hellesoy Created By Jawad Khan Sr. Automation Engineer (7+ Exp)
  • 2.
    AGENDA » Automated AcceptanceTests? » What is TDD and What is BDD? » What is Cucumber? How it works? » Cucumber Variants » Demo Cucumber for Java 2
  • 3.
    What is AutomatedAcceptance Tests? » Stakeholder and DEV team collaborate & write automated tests that express the outcome of product » Test fails at the time of writing, because no code has been written yet but capture the clear requirements » Development will continue until all cases are passed » AA tests help your team to focus and ensure the work direction 3 Page: 4
  • 4.
    Test Driven Development(TDD) 4 The approach in TDD is “Write Test first and then development will follow the test cases for further development. inshort “Tests Drive the Development” Note: In TDD, unit test, functional test and acceptance test can be acceptable based on requirements.
  • 5.
    How to performTDD Test 5
  • 6.
  • 7.
    BDD - BehaviorDriven Development » It is a software development technique & an extension of TDD » It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. » Test cases are written in a natural language that even non- programmers can read » BDD test can be useful for Product Owner, BA, Dev and Manual/Automation QA 7
  • 8.
    BDD Tests Benefits »Helps both Manual/Automation Testers in requirement understanding » Helps in both Manual/Automation Testing » Adaptability » Ubiquitous Language » Living Documentation » Source of Truth 8 Page: 5-7
  • 9.
    What is Cucumber-BDD? Cucumberis a testing tool with approach which supports Behavior Driven Development (BDD). It explains the behavior of the application in a simple English text using Gherkin language. 9
  • 10.
  • 11.
  • 12.
    What’s Gherkin For? Gherkinis the format for cucumber specifications. It is a domain specific language which helps you to describe business behavior without the need to go into detail of implementation. 12
  • 13.
    Format and Syntax Gherkinfiles use the .feature file extension. They’re saved as plain text, meaning they can be read and edited with simple tools. In this respect, Gherkin is very similar to file formats like Markdown, Textile, and YAML. 13
  • 14.
    Keywords A Gherkin fileis given its structure and meaning using a set of special key-words. » Feature » Background » Scenario » Given » When » Then » And » But » Scenario Outline » Examples 14
  • 15.
  • 16.
    Requirement Specification Documentation InTraditional Style 16 Payment application business cases
  • 17.
  • 18.
  • 19.
  • 20.
    Important Things aboutCucumber 20 Stateless: Each scenario must make sense and be able to be executed independently of any other scenario Comments: Spoken Languages: 70+ languages (https://bit.ly/2ANiXlt) )
  • 21.
  • 22.
  • 23.
    Feature File &Java Class 23 » Steps and Step Definitions » Matching a Step » Creating a Step Definition
  • 24.
    Regular Expressions inStep Def. 24 Capture Groups Alternative More RE on Page:53
  • 25.
    Cucumber Test ResultsStatus 25 » Failed » Pending » Undefined » Skipped » Passed Read Page:60
  • 26.
  • 27.
    Cucumber Background 27 A backgroundsection in a feature file allows you to specify a set of steps that are common to every scenario in the file. Read Page:69
  • 28.
    Cucumber Data Tables 28 Datatables give you a way to extend a Gherkin step beyond a single line to include a larger piece of data Read Page:74
  • 29.
    Cucumber Scenario Outline 29 Canbe use when same test case need to execute on different provided data Read Page:81
  • 30.
    Cucumber Tags 30 Tags arethe sticky notes you’ve put on pages you want to be able to find easily Read Page:88
  • 31.
    Cucumber Hooks 31 Cucumber supportshooks, which are methods that run before or after each scenario. Read Page:156
  • 32.
    THANKS! Any questions? You canfind me at » LinkedIn: linkedin.com/in/jawadkhan92 » FB Group: facebook.com/groups/SirJawadKhan » Email: jawadkhan.tutor@gmail.com 32