33

BDD in Automation Testing

Embed Size (px)

Citation preview

Page 1: BDD in Automation Testing
Page 2: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Who Am I?

My name Nguyen Thi Hong Thuy

Studied at Danang University of Technology

Master of Computer Science

IT developing experience started at University in 2004

Java Developer at MagRabbit VN

Java Developer, Tester at Axon Active VN

Email [email protected]

Page 3: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

The Importance of Requirements Behavior Driven Developments (BDD)

• Why born BDD?• What is BDD?• Why use BDD?• BDD Style & Tools

How we have applied BDD in our projects Workshop Conclusion of BDD Q&A

Agenda

Page 4: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

The importance of requirements

Page 5: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

The importance of requirements

Page 6: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

The importance of requirements

Page 7: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Behavior Driven Developments

Page 8: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Test-driven development is a method of software development in which unit testing is repeatedly done on source code

TDD

Workflow of TDD

REFACTORGREEN

(Pass)

RED(Fail)

REPEAT PROCESS

1. Write a test that fails

2. Make only enough code for it to pass

3. Improve code quality

Page 9: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Why born BDD?

Page 10: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

What is BDD?

Behavior-Driven Development (BDD) is a set of

software engineering practices designed to help

teams build and deliver more valuable, higher quality

software faster.

Page 11: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

BDD

Building the right software

Automated Acceptance Criteria

API and code design

Building the software right

Feature injection

Collaboration

Living Documentation

What is BDD?

Page 12: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Workflow of TDD/BDD

BDD was originally designed as an improved version of TDD

TDD

BDD

Refactor

n cycles

Make the test pass

Write a failing test

Write a failing feature test

Page 13: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Customer tells the business analyst what he wants

Why use BDD?

The business analyst writes a requirements document

The developer translates the requirements into software

The tester translates the requirements into test cases

Customer

The traditional development process

Page 14: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

There are many opportunities for information to get lost in

translation, be misunderstood, or just be ignored

Chances are that the new module itself may not do exactly what

was required and that the documentation won’t reflect the initial

requirements

Problems

Page 15: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Why use BDD?

The development process is applying BDD

Customer and BA have a conversation about what he needs.

BA, the developer and the tester elaborate the requirements together

The automated tester The manual tester

The developer

Customer

Page 16: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

BDD Style – Feature file example

Meta:Narrative:In order to login ZingPoll successfullyAs a userI want to have single choice pollSo that I can create polls, share it to my friends & collect the option about it

Scenario: Create a single choice poll successfulGiven I am on ZingPoll websiteWhen I click the Sign In button on the menu bar to register an new accountThen The Sign In form should be shownWhen I enter email <email> and password <password>And I click the Sign In button on the formThen I log in into website successfulWhen I enter <question> into the question fieldAnd I enter the <first_anwser> and <second_answer> into the answer fieldsAnd I click the Create Poll buttonThen The poll is created successfully

Examples:|email |password |question |first_anwser|second_answer|[email protected] | zingpoll | Have you ever applied BDD in your project? |Yes |No|

Feature

Scenario

What business outcomes are you trying to achieve?

Who needs it ?

What must you do to help achieve this outcome?

Each row represents separate set of test data

Page 17: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Feature: Login ZingPoll system

As a userI want to login to Zingpoll websiteSo that I can use all features

Who’s using the system? What are they doing?

Why do they care?

BDD Style – Feature file example

Page 18: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Scenario: Login ZingPoll system successful

Given I am on ZingPoll website

When I click the Sign In button on the menu bar to register an new

account

Then The Sign In form should be shown

When I enter email <email> and password <password>

And I click the Sign In button on the form

Then I log in into website successful

• Given - Sets up preconditions, or context, for the scenario • When - The action, or behavior, that we’re focused on• Then - Checks post-conditions and verifies that the right thing happened in the When stage

BDD Style – Feature file example

Page 19: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

The principal activities and outcomes of BDD

Business goal Features Examples Executable specifications

Low-levelspecifications

Application codeLiving

documentation

Real-timeprogress reports

Technicaldocumentation

Automaticvalidation

Page 20: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

The principal activities and outcomes of BDD

Examples Executable specifications

Low-levelspecifications

Application code

Page 21: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

How we have applied BDD in our current projects

Page 22: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Repositories

Page 23: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Build Jenkins

Page 24: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Pipeline

Page 25: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Workshop

Page 26: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Introduce ZingPoll Website

Page 27: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

The Business Rules layer

The Business Flow layer

The Technical layer

Well-written automated acceptance criteria

Page 28: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Workshop

Story 1: As a ZingPoll userI want to login to ZingPoll websiteSo that I can use all features

Page 29: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Workshop

Story 2: As a ZingPoll userI want to have single choice pollSo that I can create polls, share it to my friends & collect the option about it

Page 30: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Conclusion of BDD

Focus effort

Reduce waste and misaligned requirement

Deliver more valuable software

Make changes safety

Faster and more reliable releases

Reduced maintenance costs

Page 31: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Potential challenges of BDD

BDD requires high business engagement and collaboration

BDD works best in an Agile or iterative context

Poorly written tests can lead to higher test-maintenance costs

Page 32: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Q&A

Page 33: BDD in Automation Testing

www.axon.vnfb.com/AxonActiveVietNam

Thanks for your attention