BDD Process And Test Automation -Vikas Mathur€¦ · BDD And TDD Both test driven ... Step...

Preview:

Citation preview

BDD Process And Test

Automation

-Vikas Mathur

Agenda

Perception/Misunderstanding

BDD

Gherkin

Collaboration

Best Practices/Anti-Patterns

Demo

Perception

Impact of Misunderstanding

Implementation based on misunderstanding

Codebase integrity corrupted

Other developers might already start using the code

Cost of fixing defects

BDD

Behavior Driven Development

User/system focus

Ubiquitous language understood by everyone

Collaboration

BDD And TDD

Both test driven approach

TDD developer focused

TDD tests implementation

BDD tests behavior

Not competing

Importance of Collaboration

Three amigos

Better Collaboration

Specs by Examples

Reqs that provide tests

BDD Process

Gherkin Syntax

Other Keywords

Feature

Scenario

Background

And

But

Examples

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.

BDD Acceptance Criteria

[Feature Name]

[Scenario Name]

GIVEN [initial context]

WHEN [event occurs]

THEN [ensure some outcomes]

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 |

Benefits

Common Language

Active Documentation

Easier to Test; feeds automation

Better communication/Collaboration

Test Automation

BDD an automation tool??

Acceptance tests

Unit/Integration tests

Gherkin Tools

Cucumber/Specflow

Serenity (Cucumber/Jbehave)

HipTest

Lettuce

API Tools like Karate

Building Cucumber Tests

Tests built from features

Feature - 1 or more scenario

Scenarios - set of steps

Step Definition

Supporting Classes/Utilities

Other Integrations

Hierarchy

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

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

When BDD won’t work?

Legacy silos in the team

Less Collaboration

Less Automation

Automation Process

Automated tests

Repo

CI/CD

Execution Environments

Reports

Notifications

Defects

Q&A

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/

Recommended