automation best practices 4 - tcqaa...• automation as test case management • automate your bugs....

25
Automation Best Practices for CI/CD Leo Laskin, Sr. Solutions Architect

Upload: others

Post on 14-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

A u t o m a t i o n B e s t P r a c t i c e s f o r C I / C D

L e o L a s k i n , S r . S o l u t i o n s A r c h i t e c t

Page 2: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Agenda

Topic 1CI/CD

Topic 2Best Practice Testing

Topic 3Selenium Testing

Topic 4Other tips

Page 3: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

THE PATH TO CI/CD

October 16, 2018 © Sauce Labs, Inc. 3

Continuous Delivery

Fully automated Development process

ContinuousTesting

Dev. and QA functions merge

Continuous Integration

Agile Practice Embraced

Automated testing dominates;

manual only for debugging

Dev. and QA collaborate closely

Fast Waterfall

Initial adoption of Agile

Automated testing begins

Dev. & QA start communicate

Waterfall

Traditional sequential design model

Manual testing dominates

Dev. & QA completely separate

Process

People

Tools

Page 4: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

THE MODERN DEVELOPMENT TOOL CHAIN

august, 2017 © Sauce Labs, Inc. 4

D E V O P S

C O N T I N U O U S T E S T I N G

Page 5: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Agenda

Topic 1CI/CD

Topic 2Best Practice Testing

Topic 3Selenium/Appium Testing

Topic 4Organizational Advice

Page 6: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Manual Tests Improve Automat ion

© Sauce Labs, Inc. 6

• Automation as Test Case Management

• Automate your bugs

Page 7: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Start with a Clean System

• Having a clean system every time is paramount for reproducible results

• SaaS grid based systems can be setup to be fresh with no system cache, browser cache, cookies, etc.

© Sauce Labs, Inc. 7

Page 8: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Paral le l izat ion

• Serialized tests take more time and cost more money

• 300 minute long tests can take either 5 hours or as little as 1 minute.

• Using a Selenium Grid like Sauce Labs, parallelized tests can spin up multiple browsers for you or multiple tests simultaneously

© Sauce Labs, Inc. 8

Page 9: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Test Constant ly

• Don’t ever stop testing

• Having tests run on every commit is going to provide significantly higher confidence in your software

• You have unlimited amounts of time to test. Use it!

© Sauce Labs, Inc. 9

Page 10: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Speed th ings up

• The average attention span of an adult is less then 5 minutes

• Try to provide results before context is switched

• Make the devs work for you not against you

© Sauce Labs, Inc. 10

Page 11: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Start Smal l

• Don’t rush to automate every test case

• Identify test case priority then automate

© Sauce Labs, Inc. 11

Page 12: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Avoid Dependencies

• Don’t allow tests to be dependent on each other

• One test’s actions should not drive another tests assertion criteria

• Dependent tests run slower because of a need to wait for a prior test

© Sauce Labs, Inc. 12

Page 13: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Focus On Automat ion Pyramid

© Sauce Labs, Inc. 13

Page 14: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Automat ion = Development Act iv i ty

• Automation is a real development endeavor, treat it as such

• Beware of Cowboy Coding / Parachute Drop Coding

• Copy/Pasting inside your code can be replaced by reusable methods

• Source control is cheap insurance

• Bad coding practices = bad testing practices (and vice versa)

© Sauce Labs, Inc. 14

Page 15: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Test in the r ight p lace

October 16, 2018 © Sauce Labs, Inc. 15

Page 16: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Agenda

Topic 1CI/CD

Topic 2Best Practice Testing

Topic 3Selenium Testing

Topic 4Organizational Advice

Page 17: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Selector Strategy

• What selectors do you use?

• XPath vs the rest

• Ideal Ordering

• ID• Name• CSS Selector*• Xpath

*https://code.tutsplus.com/tutorials/the-30-css-selectors-you-must-memorize--net-16048

© Sauce Labs, Inc. 17

Page 18: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Selector Strategy

© Sauce Labs, Inc. 18

Xpath: //div[@id=‘searchform’]/div/form//input[@id=‘gbqfbb’]CSS: #gbqfbb

Page 19: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Page Object Pattern

• Encourage reusable code throughout your test app

• Test code more organized for update if test parameters like selectors change

• Tests are more readable with natural feeling definition and variable naming

© Sauce Labs, Inc. 19

Page 20: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Wait ing

• Thread.sleep

• Implicit Waits

• Explicit and Fluent Waits

© Sauce Labs, Inc. 20

Page 21: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

End Your Test

© Sauce Labs, Inc. 21

• End the Test

• Don’t perform actions after Assertion

• Multiple simultaneous assertions are OK

Page 22: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Agenda

Topic 1CI/CD

Topic 2Best Practice Testing

Topic 3Selenium/Appium Testing

Topic 4Organizational Advice

Page 23: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Prep Your Environment

• Make sure your CI rig can handle the number of jobs running on it simultaneously

• Make sure your SUT can handle the number of tests running on it simultaneously

© Sauce Labs, Inc. 23

Page 24: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

Collect Metr ics

• Green or Red Build

• How many tests were run in the last 24 hours?

• How many bugs do automated tests identify per release?

© Sauce Labs, Inc. 24

Page 25: Automation Best Practices 4 - TCQAA...• Automation as Test Case Management • Automate your bugs. ... Focus On Automation Pyramid ... • Automation is a real development endeavor,

test.allTheThings()