But I Know What I LikeAbstraction is the Key to Automation(@dylanlacey -- Sauce Labs)
Preheat the oven to 375 DegreesCream 250g of butter and 1 cup of sugarin a mixing bowlMix in 2 cups of flour and 1 cup of ...
Set the Temperature Dial of the Oven to 375 Degrees FahrenheitPlace 250g of butter into the bowl of a mixerPlace 1 cup of ...
Set the Temperature Dial of the Oven to 375 Degrees FahrenheitPlace a bowl on a scaleTurn the scale on by pressing the “on...
Being Specific is Reliable
PFFT WHATEVER
You Have Questions.Who is this loudmouth?Why am I even listening to him?What time is Morning Tea?Gee I love bacon.••••
Who is this guy?
What is he talkingabout?What is a Good Abstraction?How Abstraction makes for AutomationAbstraction of ScriptsAbstraction o...
What AreAbstractions?
Good Abstractions Are:Not “Leaky”Understanding Enhancing(For our purposes) Shareable•••
Abstraction is TotesGreat
Set the Temperature Dial of the Oven to 375 Degrees FahrenheitPlace a bowl on a scaleTurn the scale on by pressing the “on...
Actually, screw cake.
Go to ChucksDrink a Lowenbrau DunkelTake a shot of TequilaDrink a White Rabbit Pale AleTake a sip of Natural IceGrimace an...
Go to ChucksDrink a Lowenbrau DunkelTake a shot of TequilaDrink a White Rabbit Pale AleTake a sip of Natural IceGrimace an...
Abstraction forScriptsMaintenance(Easier)Creation(Faster)/
Abstraction forInfrastructureExecution(Faster)Maintenance(Easier)/
TESTINGIS ALREADYABSTRACTION
Abstraction forScripting(2ish minutes of PageObjects)
PageObjects areAbstractMethods for “Doin’ Stuff” on a pageShould return Page Objects when givingnew pagesEncapsulate funct...
Abstraction forScripting(15 minutes of Capybara)
Go to ChucksDrink a Lowenbrau DunkelTake a shot of TequilaDrink a White Rabbit Pale AleTake a sip of Natural IceGrimace an...
That’s what Capybaradoes. No, really.
Capybara for Everyone!Free, open source tool, widely used bythe Ruby CommunityAble to run “headless” for JS-free testingAb...
Capybara Basicsfind_xpath ‘//table tr’find_css ‘table.tr.beer’find_field(‘mixer’).valuefind(#pantry).find(‘vermouth’)••••
Capybara Basicshas_css? ‘#sobriety’has_xpath? ‘//table tr’has_content? ‘shaken’•••
Capybara Basicsclick_link ‘http://www.hendricksgin.com’click_button ‘skoll’click_on ‘blender’•••
Capybara exact &matchCapybara.exact = trueAll future matches must be exactDefault false -> Gin matches Gin and Tonicclick_...
Capybara with Formsvisit ‘/login’fill_in ‘first_name’, :with => “Dylan”fill_in ‘last_name’, :with => “Lacey”select(‘Ruby’)...
Scopes Save you fromSelector Hellwithin ‘party’ dofill_in :pint, :with => “Kilkenny”endfind(‘#barfridge’).click_link ‘open’
Human Readable?
Human Readable.
Abstraction forScripting(15 minutes of Cucumber)
Write Tests InEngl“ish”(Technically it’s ‘gherkin’)Scenario: I am SoberGiven I am on http://en.wikipedia.org/wiki/Main_Pag...
It’s not MagicFeatures in Gherkin are implemented by‘step definitions’You/r team write the step definitionsStep definition...
That feature SUCKEDScenario: I am SoberGiven I am on Wikipedia’s Main PageWhen I search for “Old Fashioned”Then I should s...
Abstractions AllowMaintenanceGiven there is a user JackAnd Jack owns a breweryAnd Jack has a paid accountAnd Jack enters h...
Abstractions AllowMaintenanceWhen A Brewer Logs InThen I should take a shotAWESOME
Don’t Hide Too MuchBackgrounds => Steps run before each featurebackground:Given Jack is a BrewerAnd Jack has not paid his ...
Cucumber meansmaking nice withDevelopers
Developer Facts:Developers get really involved in theirworkWe’re sorry about the time we got madat you for that one thingD...
Sell to Developers:You’re both focused on Customer QualityYou both want to do excellent work“My Job is to make *YOU* look ...
Test + Dev with CukeWork together to build good testsDevs give step support and get tests anddiagnosticsTesters give exper...
Abstraction forInfrastructureExecution(Faster)Maintenance(Easier)/
Selenium requiresALL THE THINGSChrome, Safari, Opera,IE, FirefoxMULTIPLIED BYMac 10.8, WindowsXP/7/8, Linux, iOS?!MULTIPLI...
Make it someone else’sproblemSelenium GridVirtual MachinesThird Party Services•••
Selenium GridCHEAP EASY FASTTo ObtainTo OperateTo DistributeTo ParallelizeTo SetupTo Deploy(EC2)(Abstract Browsers)
I <3 VMsCHEAP EASY FASTTo RunTo ReplicateTo ShareTo RestoreTo UpdateTo BackupTo DuplicateTo SetupTo Destroy(Abstract Compu...
Why Not Both?Easy ParallelizationPlatforms you otherwise can’t supportSignificantly lower staff & infrastructurecosts•••
3rd Party ServicesCHEAP EASY FASTCapacityXtra Features (?)MaintenanceIntegration (?)UpdatingTeam Work (?)Access To NewPara...
Selenium Grid+3rd Party VMs=Parallel Heaven
Abstraction forInfrastructureBonus!Appium
Appium(Abstract ...Devices?!)Native App Automation withSeleniumAny Selenium Webdriver ToolNo App modificationsTotally Free...
How to AppiumDownload and Install Appium fromhttp://www.appium.ioRun Appium with your AppWrite your tests using the Seleni...
WAAAAA I Don’tHave a Mac!Contributes to theAppium ProjectRuns Appium in theirCloudIs working onAndroid support•••
Questions?(@dylanlacey)(dylan@saucelabs.com)
ResourcesPlay with Sauce Labs:1000 Manual Minutes200 Automated MinutesPromo Code: TestLearnPlay (exp3/14)Our Blog: http://...
Tools & LinksCapybara: https://github.com/jnicklas/capybaraCucumber: http://cukes.info/Appium: http://appium.io/Supported ...
But I Know What I Like: Abstraction is the Key to Automation
Upcoming SlideShare
Loading in...5
×

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

622

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
622
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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

  1. 1. But I Know What I LikeAbstraction is the Key to Automation(@dylanlacey -- Sauce Labs)
  2. 2. Preheat the oven to 375 DegreesCream 250g of butter and 1 cup of sugarin a mixing bowlMix in 2 cups of flour and 1 cup of milk,and combineMix in 2 tsp of vanilla extractPour into prepared tins and bake 1 hour•••••The Exhausting Reality
  3. 3. Set the Temperature Dial of the Oven to 375 Degrees FahrenheitPlace 250g of butter into the bowl of a mixerPlace 1 cup of sugar into the same bowlTurn the mixer onto “7”Mix until the mixture is pale yellowTurn the Mixer down to “1”Add 2 cups of flour to the mixing bowlAdd 1 cup of milk to the mixing bowlAllow the mixer to run until the mixture looks the same colour throughoutAdd 2tsp of Vanilla to the mixing bowl••••••••••The Exhausting Reality
  4. 4. Set the Temperature Dial of the Oven to 375 Degrees FahrenheitPlace a bowl on a scaleTurn the scale on by pressing the “on” buttonUse a knife to cut a stick of butter into 100 slicesPlace one slice into the bowl on the scaleRead the ScaleContinue to place slices of butter into the bowl until the scale reads ‘250g’Open a container of sugarGet a dry cup measure from the drawerScoop sugar from the container into the measuring cup until it reaches the topof the cupDraw the back of a knife across the surface of the measuring cup, allowing theexcess sugar to fall back into the canisterPlace the measuring cup on the counterTake the mixer out of the cupboardPlace the mixer on the benchInsert the square blade into the right hand blade hole on the mixerInsert the round blade into the left hand blade hole on the mixerThe Exhausting Reality
  5. 5. Being Specific is Reliable
  6. 6. PFFT WHATEVER
  7. 7. You Have Questions.Who is this loudmouth?Why am I even listening to him?What time is Morning Tea?Gee I love bacon.••••
  8. 8. Who is this guy?
  9. 9. What is he talkingabout?What is a Good Abstraction?How Abstraction makes for AutomationAbstraction of ScriptsAbstraction of Infrastructure••••
  10. 10. What AreAbstractions?
  11. 11. Good Abstractions Are:Not “Leaky”Understanding Enhancing(For our purposes) Shareable•••
  12. 12. Abstraction is TotesGreat
  13. 13. Set the Temperature Dial of the Oven to 375 Degrees FahrenheitPlace a bowl on a scaleTurn the scale on by pressing the “on” buttonUse a knife to cut a stick of butter into 100 slicesPlace one slice into the bowl on the scaleRead the ScaleContinue to place slices of butter into the bowl until the scale reads ‘250g’Open a container of sugarGet a dry cup measure from the drawerScoop sugar from the container into the measuring cup until it reaches the topof the cupDraw the back of a knife across the surface of the measuring cup, allowing theexcess sugar to fall back into the canisterPlace the measuring cup on the counterTake the mixer out of the cupboardPlace the mixer on the benchInsert the square blade into the right hand blade hole on the mixerInsert the round blade into the left hand blade hole on the mixerThe Exhausting Reality
  14. 14. Actually, screw cake.
  15. 15. Go to ChucksDrink a Lowenbrau DunkelTake a shot of TequilaDrink a White Rabbit Pale AleTake a sip of Natural IceGrimace and Skoll The RestWash it out with a Stein ofWiheinstephanerSleep in a doorway••••••••
  16. 16. Go to ChucksDrink a Lowenbrau DunkelTake a shot of TequilaDrink a White Rabbit Pale AleTake a sip of Natural IceGrimace and Skoll The RestWash it out with a Stein ofWiheinstephanerSleep in a doorwayExperience Regret•••••••••Go to ChucksDrink 4 BeersTake a shotSleep in a doorwayExperience Regret•••••
  17. 17. Abstraction forScriptsMaintenance(Easier)Creation(Faster)/
  18. 18. Abstraction forInfrastructureExecution(Faster)Maintenance(Easier)/
  19. 19. TESTINGIS ALREADYABSTRACTION
  20. 20. Abstraction forScripting(2ish minutes of PageObjects)
  21. 21. PageObjects areAbstractMethods for “Doin’ Stuff” on a pageShould return Page Objects when givingnew pagesEncapsulate functionality and providesingle-line access to tasksRuby has SitePrism, page_objects_gem••••
  22. 22. Abstraction forScripting(15 minutes of Capybara)
  23. 23. Go to ChucksDrink a Lowenbrau DunkelTake a shot of TequilaDrink a White Rabbit Pale AleTake a sip of Natural IceGrimace and Skoll The RestWash it out with a Stein ofWiheinstephanerSleep in a doorwayExperience Regret•••••••••Go to ChucksDrink 4 BeersTake a shotSleep in a doorwayExperience Regret•••••
  24. 24. That’s what Capybaradoes. No, really.
  25. 25. Capybara for Everyone!Free, open source tool, widely used bythe Ruby CommunityAble to run “headless” for JS-free testingAble to use Selenium to drive browsers•••
  26. 26. Capybara Basicsfind_xpath ‘//table tr’find_css ‘table.tr.beer’find_field(‘mixer’).valuefind(#pantry).find(‘vermouth’)••••
  27. 27. Capybara Basicshas_css? ‘#sobriety’has_xpath? ‘//table tr’has_content? ‘shaken’•••
  28. 28. Capybara Basicsclick_link ‘http://www.hendricksgin.com’click_button ‘skoll’click_on ‘blender’•••
  29. 29. Capybara exact &matchCapybara.exact = trueAll future matches must be exactDefault false -> Gin matches Gin and Tonicclick_link(“jigger”, exact: true)Capybara.match = prefer_exactSets strategy for multiple matchesDefault ‘smart’, also one, first, prefer_exactclick_link(“shout”, match: one)
  30. 30. Capybara with Formsvisit ‘/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’)
  31. 31. Scopes Save you fromSelector Hellwithin ‘party’ dofill_in :pint, :with => “Kilkenny”endfind(‘#barfridge’).click_link ‘open’
  32. 32. Human Readable?
  33. 33. Human Readable.
  34. 34. Abstraction forScripting(15 minutes of Cucumber)
  35. 35. Write Tests InEngl“ish”(Technically it’s ‘gherkin’)Scenario: I am SoberGiven I am on http://en.wikipedia.org/wiki/Main_PageWhen I enter "Old Fashioned" into the search boxAnd I click the searchButtonThen I should see "The Old Fashioned is an IBA Official Cocktail"
  36. 36. It’s not MagicFeatures in Gherkin are implemented by‘step definitions’You/r team write the step definitionsStep definitions can be any codeStep definitions can be many programminglanguages••••
  37. 37. That feature SUCKEDScenario: I am SoberGiven I am on Wikipedia’s Main PageWhen I search for “Old Fashioned”Then I should see the “Old Fashioned” entry
  38. 38. Abstractions AllowMaintenanceGiven 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
  39. 39. Abstractions AllowMaintenanceWhen A Brewer Logs InThen I should take a shotAWESOME
  40. 40. Don’t Hide Too MuchBackgrounds => Steps run before each featurebackground:Given Jack is a BrewerAnd Jack has not paid his billScenario: Jack orders something deliciousWhen Jack orders Woodford ReserveThen Jack sees “Shove Off”Scenario: Jack orders something grossWhen Jack orders TequilaThen Jack sees “This time, but pay up!”
  41. 41. Cucumber meansmaking nice withDevelopers
  42. 42. Developer Facts:Developers get really involved in theirworkWe’re sorry about the time we got madat you for that one thingDevelopers want the same thing youwant: Better ProductY’all are as smart as them, if not smarter(don’t tell them I said that)••••
  43. 43. Sell to Developers:You’re both focused on Customer QualityYou both want to do excellent work“My Job is to make *YOU* look good”(Thanks, JeanAnn Harrison!)•••
  44. 44. Test + Dev with CukeWork together to build good testsDevs give step support and get tests anddiagnosticsTesters give expert advice and get flexibletoolsYou can use different dev & test languagesDANGER: Don’t let the devs make setup•••••
  45. 45. Abstraction forInfrastructureExecution(Faster)Maintenance(Easier)/
  46. 46. Selenium requiresALL THE THINGSChrome, Safari, Opera,IE, FirefoxMULTIPLIED BYMac 10.8, WindowsXP/7/8, Linux, iOS?!MULTIPLIED BYVersions!•••
  47. 47. Make it someone else’sproblemSelenium GridVirtual MachinesThird Party Services•••
  48. 48. Selenium GridCHEAP EASY FASTTo ObtainTo OperateTo DistributeTo ParallelizeTo SetupTo Deploy(EC2)(Abstract Browsers)
  49. 49. I <3 VMsCHEAP EASY FASTTo RunTo ReplicateTo ShareTo RestoreTo UpdateTo BackupTo DuplicateTo SetupTo Destroy(Abstract Computers)
  50. 50. Why Not Both?Easy ParallelizationPlatforms you otherwise can’t supportSignificantly lower staff & infrastructurecosts•••
  51. 51. 3rd Party ServicesCHEAP EASY FASTCapacityXtra Features (?)MaintenanceIntegration (?)UpdatingTeam Work (?)Access To NewParalleling (?)CI(Abstract Solutions)(?) = Dependant on Provider?
  52. 52. Selenium Grid+3rd Party VMs=Parallel Heaven
  53. 53. Abstraction forInfrastructureBonus!Appium
  54. 54. Appium(Abstract ...Devices?!)Native App Automation withSeleniumAny Selenium Webdriver ToolNo App modificationsTotally Free and Open Source!(Mac client only ATM. Sorry >.>)
  55. 55. How to AppiumDownload and Install Appium fromhttp://www.appium.ioRun Appium with your AppWrite your tests using the SeleniumWebdriver JSON Subset:https://github.com/appium/appium/wiki/JSON-Wire-Protocol:-Supported-MethodsRun your tests••••
  56. 56. WAAAAA I Don’tHave a Mac!Contributes to theAppium ProjectRuns Appium in theirCloudIs working onAndroid support•••
  57. 57. Questions?(@dylanlacey)(dylan@saucelabs.com)
  58. 58. ResourcesPlay with Sauce Labs:1000 Manual Minutes200 Automated MinutesPromo Code: TestLearnPlay (exp3/14)Our Blog: http://www.sauceio.com•••••
  59. 59. Tools & LinksCapybara: https://github.com/jnicklas/capybaraCucumber: http://cukes.info/Appium: http://appium.io/Supported methods: http://goo.gl/MiPcHRuby examples: http://goo.gl/uQGh5Sauce Labs Sign Up: http://goo.gl/uBTXX••••••
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×