25
BDD Process And Test Automation -Vikas Mathur

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

  • Upload
    others

  • View
    3

  • Download
    1

Embed Size (px)

Citation preview

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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
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

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

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/