BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step...
Transcript of BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step...
![Page 1: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/1.jpg)
BDD Process And Test
Automation
-Vikas Mathur
![Page 2: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/2.jpg)
Agenda
Perception/Misunderstanding
BDD
Gherkin
Collaboration
Best Practices/Anti-Patterns
Demo
![Page 3: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/3.jpg)
Perception
![Page 4: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/4.jpg)
Impact of Misunderstanding
Implementation based on misunderstanding
Codebase integrity corrupted
Other developers might already start using the code
Cost of fixing defects
![Page 5: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/5.jpg)
BDD
Behavior Driven Development
User/system focus
Ubiquitous language understood by everyone
Collaboration
![Page 6: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/6.jpg)
BDD And TDD
Both test driven approach
TDD developer focused
TDD tests implementation
BDD tests behavior
Not competing
![Page 7: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/7.jpg)
Importance of Collaboration
Three amigos
Better Collaboration
Specs by Examples
Reqs that provide tests
![Page 8: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/8.jpg)
BDD Process
![Page 9: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/9.jpg)
Gherkin Syntax
![Page 10: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/10.jpg)
Other Keywords
Feature
Scenario
Background
And
But
Examples
![Page 11: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/11.jpg)
Standard User Story
User Stories are often written as:
As a [role] I need [feature] so that [benefit].
As a customer I want to withdraw money from an ATM so that I don’t have to go
to the bank.
![Page 12: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/12.jpg)
BDD Acceptance Criteria
[Feature Name]
[Scenario Name]
GIVEN [initial context]
WHEN [event occurs]
THEN [ensure some outcomes]
![Page 13: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/13.jpg)
Gherkin Example
Feature: Google Search
Scenario Outline: Search for state capitals
Given the student selects to search using Google
When the student searches for capital of "<state>"
Then search results are displayed using "<capital>"
Examples:
| state | capital |
| Iowa | Des Moines |
| Kansas | Topeka |
![Page 14: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/14.jpg)
Benefits
Common Language
Active Documentation
Easier to Test; feeds automation
Better communication/Collaboration
![Page 15: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/15.jpg)
Test Automation
BDD an automation tool??
Acceptance tests
Unit/Integration tests
![Page 16: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/16.jpg)
Gherkin Tools
Cucumber/Specflow
Serenity (Cucumber/Jbehave)
HipTest
Lettuce
API Tools like Karate
![Page 17: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/17.jpg)
Building Cucumber Tests
Tests built from features
Feature - 1 or more scenario
Scenarios - set of steps
Step Definition
Supporting Classes/Utilities
Other Integrations
![Page 18: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/18.jpg)
Hierarchy
![Page 19: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/19.jpg)
Cucumber Best Practices
Short/concise feature descriptions
Same format across different features
Hide implementation details
Given-When-Then in the right order
Refactor and reuse steps
![Page 20: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/20.jpg)
Cucumber Anti-Patterns
Features written after
writing code
Devs, QAs or BAs
writing scenarios in
isolation
Interface details
Too High-Level Scenarios
Use of the pronoun I
![Page 21: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/21.jpg)
When BDD won’t work?
Legacy silos in the team
Less Collaboration
Less Automation
![Page 22: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/22.jpg)
Automation Process
Automated tests
Repo
CI/CD
Execution Environments
Reports
Notifications
Defects
![Page 23: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/23.jpg)
![Page 24: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/24.jpg)
Q&A
![Page 25: BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step Definition ... Hide implementation details Given-When-Then in the right order Refactor](https://reader036.fdocuments.in/reader036/viewer/2022062508/6058bed462705c4062583d31/html5/thumbnails/25.jpg)
References
https://blogs.sap.com/2017/04/12/behaviour-driven-development-bdd-closing-the-loop-on-a-great-fiori-ux/
https://www.testingexcellence.com/bdd-guidelines-best-practices/
https://www.toolsqa.com/cucumber/gherkin-keywords/
https://www.toolsqa.com/cucumber/behavior-driven-development/
http://media.pragprog.com/titles/hwcuc2/intro.pdf
http://www.thinkcode.se/blog/2016/06/22/cucumber-antipatterns
https://cucumber.io/docs/guides/anti-patterns/
https://blog.testlodge.com/tdd-vs-bdd/
https://docs.behat.org/en/v2.5/guides/1.gherkin.html
https://codesthq.com/the-ugly-truth-about-software-development-process/
https://github.com/vikasmathur100/daqaa/