test automation framework with bdd and cucumber

21
BDD and Cucumber based Test Automation Frameworks Harsh Murari [email protected] Software Architect Rhoynar Software Consulting, Boulder, CO www.rhoynar.com Presented At SQUAD Meetup at Denver, CO, Oct 11, 2016

Upload: rhoynar-software-consulting

Post on 16-Apr-2017

278 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Test Automation Framework with BDD and Cucumber

BDD and Cucumber based Test Automation

FrameworksHarsh [email protected]

Software ArchitectRhoynar Software Consulting, Boulder, CO

www.rhoynar.com

Presented At SQUAD Meetup at Denver, CO, Oct 11, 2016

Page 2: Test Automation Framework with BDD and Cucumber

Job Announcements Oct 11, 2016• Senior PHP Developer: PHP, LAMP, CodeIgnitor, WebStorm• QA Automation Engineer (Boston Area): Java, TestNG,

Selenium WebDriver

Page 3: Test Automation Framework with BDD and Cucumber

About Me• Co-founder and Software Architect at Rhoynar Software

Consulting (www.rhoynar.com)• Working on Application Development, QA Automation and

Test Automation Solutions• 12+ years of Software Engineering Experience

Page 4: Test Automation Framework with BDD and Cucumber

About Rhoynar Software ConsultingFounded in 2015, providing QA automation and Continuous Delivery Services for clients in Denver/Boulder area.

Contact Us:Web: www.rhoynar.comPh.: +1-855-5-RHOYNAREmail: [email protected]

• Consulting: Application Development, QA Automation and DevOps

• Staffing: Highly Experienced Candidates

• Training: 3-5 days customized training courses

Page 5: Test Automation Framework with BDD and Cucumber

About This Presentation: Objectives• Motivation and Background: • Open-source initiatives from Rhoynar• Continuous Integration Infrastructure• Email Notification Verification• AutoTestR – Automatic Page Object Generation

• BDD and Cucumber• Overview of BDD – Behavior Driven Development Model and Cucumber• Integration of Selenium WebDriver, Page Objects and Models Design Pattern• BDD and Test Automation Best Practices• BDD Demo

Page 6: Test Automation Framework with BDD and Cucumber

Open Source Initiatives From Rhoynar

: https://github.com/Rhoynar

Page 7: Test Automation Framework with BDD and Cucumber

Continuous Integration Infrastructure

https://github.com/Rhoynar/ci-infra

Page 8: Test Automation Framework with BDD and Cucumber

CI Infra Workflow

https://github.com/Rhoynar/ci-infra

Page 9: Test Automation Framework with BDD and Cucumber

AutoTestR – Page Object Auto Generation

• AutoTestR uses node.js framework to parse the DOM for the page and generate corresponding test object code.

https://github.com/Rhoynar/AutoTestR

Page 10: Test Automation Framework with BDD and Cucumber

AutoTestR Graph Based Test Case Generation

- Each node represents a page-object (or rather business object)

- Each node specifies what are its exported interfaces, what are its next states

- Based on this graph, AutoTestR auto-generates test case skeletons as well!

- Example Test Cases:- Login->Unregistered Page- Login->Main Page->CreateUser-

>End- Login->Main Page->SearchUser-

>End- Login->Main Page->DeleteUser-

>End- Login->Main Page->Unregistered

Page

https://github.com/Rhoynar/AutoTestR

Page 11: Test Automation Framework with BDD and Cucumber

EmailVerify: Verify Email Notification Receipt

UseCase- Web Application Sends a Notification/Email

to Users- Test Automation Wants to Verify if Email has

been received?- Email with certain Subject Line has been

received?- Email with certain content has been

received? Etc

https://github.com/Rhoynar/EmailVerify

Use EmailVerify Library

- Simple to use: startMonitor(), verify(), stopMonitor()

- Multiple variations of use-cases and regular expression parsing support!

Page 12: Test Automation Framework with BDD and Cucumber

BDD/Cucumber based QA-Automation Framework

https://github.com/Rhoynar/qa-automation

• Project for barebones QA Automation Development Using:• Java• BDD• Cucumber• TestNG• Maven

Page 13: Test Automation Framework with BDD and Cucumber

What is BDD (Behavior Driven Development)?• BDD Keeps Business Behavior in sync with Software

Development• Extends Test Driven Development to cover Business

Acceptance Tests

Page 14: Test Automation Framework with BDD and Cucumber

How can I write tests without actual code?

• BDD Uses Simple English Syntax (Gherkin)• BDD uses example based ‘Scenarios’• Each ‘Scenario’ is noted in the form of ’Given’, ‘When’, ‘Then’

Page 15: Test Automation Framework with BDD and Cucumber

Outside In Approach

• Start with a conversation

• Determine the business value

• Provide Examples of use

Page 16: Test Automation Framework with BDD and Cucumber

BDD Example:

Simple Login Scenario

Step Definitions

Page 17: Test Automation Framework with BDD and Cucumber

Does this only work with Web Based Applications?• BDD can be work with any type of application!• We recently used BDD to load builds onto

Android Device.

Scenario: Load Android Build onto device

Given Device is ConnectedWhen I load the buildThen Device is detected in ADB

Automatic Conversion to Code

public void device_is_connected() {…}

public void i_load_the_build() {…}

public void device_detected_in_adb() {…}

Page 18: Test Automation Framework with BDD and Cucumber

Building Blocks of Scenarios• BDD Allows to build on top of existing scenarios easily• Existing step-defs can be re-used, only new steps need to be

written• Less Code Repetition – better regression framework

Scenario: Load Android Build onto device

Given Device is ConnectedWhen I load the buildAnd I reset the deviceThen Device is detected in ADB

With only one additional step, I have a new test case

public void device_is_connected() {…}

public void i_load_the_build() {…}

public void i_reset_device(){…}

public void device_detected_in_adb() {…}

Page 19: Test Automation Framework with BDD and Cucumber

Demo

• Yahoo Login Example • Source Code: https://github.com/Rhoynar/qa-automation

Page 20: Test Automation Framework with BDD and Cucumber

Summary

• BDD minimizes communications, hides implementation details and provides robust regression tests.• BDD Provides Building blocks of scenarios and step-

definitions, so incremental test can be written easily.

Page 21: Test Automation Framework with BDD and Cucumber

Contact Us:Rhoynar Software Consulting

Web: www.rhoynar.comPh.: +1-855-5-RHOYNAR

Email: [email protected]

ConsultingQA Automation, DevOps

and Application

Development

StaffingHighly qualified and

tech-screened candidates

TrainingCustomized onsite

training events on latest technologies