but i know what i like: abstraction is the key to automation

60
But I Know What I Like Abstraction is the Key to Automation (@dylanlacey -- Sauce Labs)

Upload: sauce-labs

Post on 09-May-2015

598 views

Category:

Business


6 download

TRANSCRIPT

Page 1: But I Know What I Like: Abstraction is the Key to Automation

But I Know What I LikeAbstraction is the Key to Automation

(@dylanlacey -- Sauce Labs)

Page 2: But I Know What I Like: Abstraction is the Key to Automation

Preheat the oven to 375 Degrees

Cream 250g of butter and 1 cup of sugarin a mixing bowl

Mix in 2 cups of flour and 1 cup of milk,and combine

Mix in 2 tsp of vanilla extract

Pour into prepared tins and bake 1 hour

••

••

The Exhausting Reality

Page 3: But I Know What I Like: Abstraction is the Key to Automation

Set the Temperature Dial of the Oven to 375 Degrees Fahrenheit

Place 250g of butter into the bowl of a mixer

Place 1 cup of sugar into the same bowl

Turn the mixer onto “7”

Mix until the mixture is pale yellow

Turn the Mixer down to “1”

Add 2 cups of flour to the mixing bowl

Add 1 cup of milk to the mixing bowl

Allow the mixer to run until the mixture looks the same colour throughout

Add 2tsp of Vanilla to the mixing bowl

Mix in 2 cups of flour and 1 cup of milk, and combine

The Exhausting Reality

Page 4: But I Know What I Like: Abstraction is the Key to Automation

Set the Temperature Dial of the Oven to 375 Degrees Fahrenheit

Place a bowl on a scale

Turn the scale on by pressing the “on” button

Use a knife to cut a stick of butter into 100 slices

Place one slice into the bowl on the scale

Read the Scale

Continue to place slices of butter into the bowl until the scale reads ‘250g’

Open a container of sugar

Get a dry cup measure from the drawer

Scoop sugar from the container into the measuring cup until it reaches the topof the cup

Draw the back of a knife across the surface of the measuring cup, allowing theexcess sugar to fall back into the canister

Place the measuring cup on the counter

Take the mixer out of the cupboard

Place the mixer on the bench

Insert the square blade into the right hand blade hole on the mixer

Insert the round blade into the left hand blade hole on the mixer

The Exhausting Reality

Page 5: But I Know What I Like: Abstraction is the Key to Automation
Page 6: But I Know What I Like: Abstraction is the Key to Automation

Being Specific is Reliable

Page 7: But I Know What I Like: Abstraction is the Key to Automation

PFFT WHATEVER

Page 8: But I Know What I Like: Abstraction is the Key to Automation

You Have Questions.

Who is this loudmouth?

Why am I even listening to him?

What time is Morning Tea?

Gee I love bacon.

••••

Page 9: But I Know What I Like: Abstraction is the Key to Automation

Who is this guy?

Page 10: But I Know What I Like: Abstraction is the Key to Automation

What is he talkingabout?

What is a Good Abstraction?

How Abstraction makes for Automation

Abstraction of Scripts

Abstraction of Infrastructure

Page 11: But I Know What I Like: Abstraction is the Key to Automation

What AreAbstractions?

Page 12: But I Know What I Like: Abstraction is the Key to Automation

Good Abstractions Are:

Not “Leaky”

Understanding Enhancing

(For our purposes) Shareable

•••

Page 13: But I Know What I Like: Abstraction is the Key to Automation

Abstraction is TotesGreat

Page 14: But I Know What I Like: Abstraction is the Key to Automation

Set the Temperature Dial of the Oven to 375 Degrees Fahrenheit

Place a bowl on a scale

Turn the scale on by pressing the “on” button

Use a knife to cut a stick of butter into 100 slices

Place one slice into the bowl on the scale

Read the Scale

Continue to place slices of butter into the bowl until the scale reads ‘250g’

Open a container of sugar

Get a dry cup measure from the drawer

Scoop sugar from the container into the measuring cup until it reaches the topof the cup

Draw the back of a knife across the surface of the measuring cup, allowing theexcess sugar to fall back into the canister

Place the measuring cup on the counter

Take the mixer out of the cupboard

Place the mixer on the bench

Insert the square blade into the right hand blade hole on the mixer

Insert the round blade into the left hand blade hole on the mixer

The Exhausting Reality

Page 15: But I Know What I Like: Abstraction is the Key to Automation

Actually, screw cake.

Page 16: But I Know What I Like: Abstraction is the Key to Automation

Go to Chucks

Drink a Lowenbrau Dunkel

Take a shot of Tequila

Drink a White Rabbit Pale Ale

Take a sip of Natural Ice

Grimace and Skoll The Rest

Wash it out with a Stein ofWiheinstephaner

Sleep in a doorway

Experience Regret

Page 17: But I Know What I Like: Abstraction is the Key to Automation

Go to Chucks

Drink a Lowenbrau Dunkel

Take a shot of Tequila

Drink a White Rabbit Pale Ale

Take a sip of Natural Ice

Grimace and Skoll The Rest

Wash it out with a Stein ofWiheinstephaner

Sleep in a doorway

Experience Regret

Go to Chucks

Drink 4 Beers

Take a shot

Sleep in a doorway

Experience Regret

Page 18: But I Know What I Like: Abstraction is the Key to Automation

Abstraction for Scripts

Maintenance(Easier)

Creation(Faster) /

Page 19: But I Know What I Like: Abstraction is the Key to Automation

Abstraction forInfrastructure

Execution(Faster)

Maintenance(Easier) /

Page 20: But I Know What I Like: Abstraction is the Key to Automation

TESTINGIS ALREADY

ABSTRACTION

Page 21: But I Know What I Like: Abstraction is the Key to Automation

Abstraction forScripting

(2ish minutes of PageObjects)

Page 22: But I Know What I Like: Abstraction is the Key to Automation

PageObjects areAbstract

Methods for “Doin’ Stuff” on a page

Should return Page Objects when givingnew pages

Encapsulate functionality and providesingle-line access to tasks

Ruby has SitePrism, page_objects_gem

••

Page 23: But I Know What I Like: Abstraction is the Key to Automation

Abstraction forScripting

(15 minutes of Capybara)

Page 24: But I Know What I Like: Abstraction is the Key to Automation

Go to Chucks

Drink a Lowenbrau Dunkel

Take a shot of Tequila

Drink a White Rabbit Pale Ale

Take a sip of Natural Ice

Grimace and Skoll The Rest

Wash it out with a Stein ofWiheinstephaner

Sleep in a doorway

Experience Regret

Go to Chucks

Drink 4 Beers

Take a shot

Sleep in a doorway

Experience Regret

Page 25: But I Know What I Like: Abstraction is the Key to Automation

That’s what Capybaradoes. No, really.

Page 26: But I Know What I Like: Abstraction is the Key to Automation

Capybara for Everyone!

Free, open source tool, widely used bythe Ruby Community

Able to run “headless” for JS-free testing

Able to use Selenium to drive browsers

••

Page 27: But I Know What I Like: Abstraction is the Key to Automation

Capybara Basics

find_xpath ‘//table tr’

find_css ‘table.tr.beer’find_field(‘mixer’).valuefind(#pantry).find(‘vermouth’)

•••

Page 28: But I Know What I Like: Abstraction is the Key to Automation

Capybara Basics

has_css? ‘#sobriety’has_xpath? ‘//table tr’has_content? ‘shaken’

•••

Page 29: But I Know What I Like: Abstraction is the Key to Automation

Capybara Basics

click_link ‘http://www.hendricksgin.com’click_button ‘skoll’click_on ‘blender’

•••

Page 30: But I Know What I Like: Abstraction is the Key to Automation

Capybara exact &match

Capybara.exact = true All future matches must be exact Default false -> Gin matches Gin and Tonic click_link(“jigger”, exact: true)

Capybara.match = prefer_exact Sets strategy for multiple matches Default ‘smart’, also one, first, prefer_exact click_link(“shout”, match: one)

Page 31: But I Know What I Like: Abstraction is the Key to Automation

Capybara with Forms

visit ‘/login’fill_in ‘first_name’, :with => “Dylan”fill_in ‘last_name’, :with => “Lacey”select(‘Ruby’), :from => “Languages”check ‘Awesome’attach_file(‘Beer’, ‘/Path/To/Beer’)

Page 32: But I Know What I Like: Abstraction is the Key to Automation

Scopes Save you fromSelector Hell

within ‘party’ do fill_in :pint, :with => “Kilkenny”end

find(‘#barfridge’).click_link ‘open’

Page 33: But I Know What I Like: Abstraction is the Key to Automation

Human Readable?

Page 34: But I Know What I Like: Abstraction is the Key to Automation

Human Readable.

Page 35: But I Know What I Like: Abstraction is the Key to Automation

Abstraction forScripting

(15 minutes of Cucumber)

Page 36: But I Know What I Like: Abstraction is the Key to Automation

Write Tests InEngl“ish”

(Technically it’s ‘gherkin’)

Scenario: I am Sober Given I am on http://en.wikipedia.org/wiki/Main_Page When I enter "Old Fashioned" into the search box And I click the searchButton Then I should see "The Old Fashioned is an IBA Official Cocktail"

Page 37: But I Know What I Like: Abstraction is the Key to Automation

It’s not Magic

Features in Gherkin are implemented by‘step definitions’

You/r team write the step definitions

Step definitions can be any code

Step definitions can be many programminglanguages

•••

Page 38: But I Know What I Like: Abstraction is the Key to Automation

That feature SUCKED

Scenario: I am Sober Given I am on Wikipedia’s Main Page When I search for “Old Fashioned” Then I should see the “Old Fashioned” entry

Page 39: But I Know What I Like: Abstraction is the Key to Automation

Abstractions AllowMaintenance

Given there is a user JackAnd Jack owns a breweryAnd Jack has a paid accountAnd Jack enters his passwordAnd Jack enters his usernameWhen he logs inThen I should take a shot BRITTLE

Page 40: But I Know What I Like: Abstraction is the Key to Automation

BRITTLE

Abstractions AllowMaintenance

When A Brewer Logs InThen I should take a shot

AWESOME

Page 41: But I Know What I Like: Abstraction is the Key to Automation

Don’t Hide Too MuchBackgrounds => Steps run before each feature

background: Given Jack is a Brewer And Jack has not paid his bill

Scenario: Jack orders something delicious When Jack orders Woodford Reserve Then Jack sees “Shove Off”

Scenario: Jack orders something gross When Jack orders Tequila Then Jack sees “This time, but pay up!”

Page 42: But I Know What I Like: Abstraction is the Key to Automation

Cucumber meansmaking nice with

Developers

Page 43: But I Know What I Like: Abstraction is the Key to Automation

Developer Facts:

Developers get really involved in theirwork

We’re sorry about the time we got madat you for that one thing

Developers want the same thing youwant: Better Product

Y’all are as smart as them, if not smarter(don’t tell them I said that)

Page 44: But I Know What I Like: Abstraction is the Key to Automation

Sell to Developers:

You’re both focused on Customer Quality

You both want to do excellent work

“My Job is to make *YOU* look good”(Thanks, JeanAnn Harrison!)

•••

Page 45: But I Know What I Like: Abstraction is the Key to Automation

Test + Dev with Cuke

Work together to build good tests

Devs give step support and get tests anddiagnostics

Testers give expert advice and get flexibletools

You can use different dev & test languages

DANGER: Don’t let the devs make setup

••

••

Page 46: But I Know What I Like: Abstraction is the Key to Automation

Abstraction forInfrastructure

Execution(Faster)

Maintenance(Easier) /

Page 47: But I Know What I Like: Abstraction is the Key to Automation

Selenium requiresALL THE THINGS

Chrome, Safari, Opera,IE, Firefox

MULTIPLIED BY

Mac 10.8, WindowsXP/7/8, Linux, iOS?!

MULTIPLIED BY

Versions!

Page 48: But I Know What I Like: Abstraction is the Key to Automation

Make it someone else’sproblem

Selenium Grid

Virtual Machines

Third Party Services

•••

Page 49: But I Know What I Like: Abstraction is the Key to Automation

Selenium Grid

CHEAP EASY FAST

To ObtainTo Operate

To DistributeTo Parallelize

To SetupTo Deploy

(EC2)

(Abstract Browsers)

Page 50: But I Know What I Like: Abstraction is the Key to Automation

I <3 VMs

CHEAP EASY FASTTo Run

To ReplicateTo Share

To RestoreTo UpdateTo Backup

To DuplicateTo Setup

To Destroy

(Abstract Computers)

Page 51: But I Know What I Like: Abstraction is the Key to Automation

Why Not Both?

Easy Parallelization

Platforms you otherwise can’t support

Significantly lower staff & infrastructurecosts

•••

Page 52: But I Know What I Like: Abstraction is the Key to Automation

3rd Party Services

CHEAP EASY FASTCapacity

Xtra Features (?)Maintenance

Integration (?)Updating

Team Work (?)

Access To NewParalleling (?)

CI

(Abstract Solutions)

(?) = Dependant on Provider?

Page 53: But I Know What I Like: Abstraction is the Key to Automation

Selenium Grid+

3rd Party VMs=

Parallel Heaven

Bonus!

Page 54: But I Know What I Like: Abstraction is the Key to Automation

Abstraction forInfrastructure

Bonus!

Appium

Page 55: But I Know What I Like: Abstraction is the Key to Automation

Appium(Abstract ...Devices?!)

Native App Automation withSelenium

Any Selenium Webdriver ToolNo App modifications

Totally Free and Open Source!

(Mac client only ATM. Sorry >.>)

Page 56: But I Know What I Like: Abstraction is the Key to Automation

How to Appium

Download and Install Appium fromhttp://www.appium.io

Run Appium with your App

Write your tests using the SeleniumWebdriver JSON Subset:https://github.com/appium/appium/wiki/JSON-Wire-Protocol:-Supported-Methods

Run your tests

••

Page 57: But I Know What I Like: Abstraction is the Key to Automation

WAAAAA I Don’tHave a Mac!

Contributes to theAppium Project

Runs Appium in theirCloud

Is working onAndroid support

Page 58: But I Know What I Like: Abstraction is the Key to Automation

Questions?(@dylanlacey)

([email protected])

Page 59: But I Know What I Like: Abstraction is the Key to Automation

Resources

Play with Sauce Labs:

1000 Manual Minutes

200 Automated Minutes

Promo Code: TestLearnPlay (exp3/14)

Our Blog: http://www.sauceio.com

••••

Page 60: But I Know What I Like: Abstraction is the Key to Automation

Tools & Links

Capybara: https://github.com/jnicklas/capybara

Cucumber: http://cukes.info/

Appium: http://appium.io/

Supported methods: http://goo.gl/MiPcH

Ruby examples: http://goo.gl/uQGh5

Sauce Labs Sign Up: http://goo.gl/uBTXX

(Don’t forget to click ‘I Have a Promo

•••

•••