33
Jumpstarting Selenium Testing in Your Organization Josh Cypher - Quality Automation Engineering Lead November 2016

Jumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIO

Embed Size (px)

Citation preview

Jumpstarting Selenium Testing in Your OrganizationJosh Cypher - Quality Automation Engineering Lead

November 2016

WE’RE ON A MISSIONTO HELP MARKETERS DO THEIR VERY BEST WORK.

CUSTOMER EXPERIENCEAN EXPERIENCE YOU AND YOUR TEAM WILL LOVE.

THE TESTING PYRAMID

Source: http://watirmelon.com

Quality As Part Of The Delivery Process

QUALITY AS PART OF THE DELIVERY PROCESS

• Test at each development stage • Unit test ALL THE THINGS• Identify boundaries between services • Test for behavior, not just function • Keep Exploring

CUSTOMER EXPERIENCEAN EXPERIENCE YOU AND YOUR TEAM WILL LOVE.

All Automation Engineers are Developers

All Developers Are Testers

THE TESTING PYRAMID

Source: http://watirmelon.com

Testing For Behavior

Cucumber WHAT

+ BDD Framework for writing plain-english statements and mapping them to test code

+ Built around Given, When & Then statements that make up the Gherkin syntax

+ Features describe Value propositions

+ Scenarios evaluate Expectations

WHO + Business People

WHY + Produces Contextual Errors + Describes Customer Intentions

Why Javascript?

Lets Use Selenium!

Selenium WHAT

+ Tool for automating web application testing by sending commands to Native Browser API's

+ Self-contained Library that is Framework-Agnostic + Supports Multiple Browsers, Proxies, & Devices

WHY + Provide a Friendly API to help write and maintain

tests + Bring Modularity & Realism to the testing

experience

HOW + Sends actionable commands to the browser and

returns data used for making assertions via the JSON Wire Protocol

WebdriverIO

Cucumber...SALAD + Cucumber draws relationships between

Gherkin Statements & Step Definitions + Test code Lives in the step definitions at it's

highest level

REGEX SUPPORT + Cucumber supports parameterization

through Regular Expressions + We can leverage regex to create a few very

Abstract step definitions that power many variations of tests

UI AUTOMATION: The Tester's Rube Goldberg Machine

The Tester's Rube Goldberg Machine

UI AUTOMATION:

Not All Assertions Are Created Equal

1. Receptacle Picked Up

2. Waste Out Of Can

Unit Tests Passed:

Design Patterns

The Page Object Pattern + CSS selectors can often change in test code, Breaking all of our automation + We place these selectors and functions in domain-specific page objects that are

shared across the Global Scope

+ We can instantiate page objects as needed for efficiency

ANOTHER LEVEL OF ABSTRACTION + The page objects become the API that interacts with the user interface + One change to a single selector is fixed in One Place

+ Pages can Inherit, Extend, or work in Isolation of one another

Dependency Injection

So Now What? Let's share it with everyone!

Page Objects

UI Map

Utility Classes

RouterDependency

Injector Steps/Specs

Selenium

Assertions

NPM Install your-test-library

HOW + Wrap all your page objects, test data, utility classes, etc in a Publishable Package

+ Treat this code like Production code

+ Push updates to the library when the front-end changes.

+ Document and treat this like any public-facing API

WHY + Test with Whatever, Wherever + Have a single source of truth for ALL your testing needs. + Get developers involved in the process

Distributed Testing

Surgeon General's Warning:

-Using PhantomJS for UI Testing Accomplishes nothing and Can lead to Flaky Results / CANCER

WILL IT BLEND?

PUTTING IT ALL TOGETHER + We test specifics from the Gherkin layer + Step definitions support multiple parameters by

leveraging regex + Page Objects are instantiated one at a time

through dependency injection + Assertions are only made at the Step definition

level + Page objects live a completely decoupled

"testing library"

DEMO TIME! LET’S TAKE A LOOK!

THANKS FOR LISTENING! LET’S DISCUSS.

github.com/dcypherthis@joshuacypher

[email protected]

Examples AUT - https://guitar-practice-app.herokuapp.com/

https://github.com/dcypherthis/gtr-test-xray https://github.com/dcypherthis/gtr-test-cucumberhttps://github.com/dcypherthis/gtr-test-mocha-bdd