What's That Smell? Tidying Up Our Test Code Presented - - PDF document

what s that smell tidying up our test code
SMART_READER_LITE
LIVE PREVIEW

What's That Smell? Tidying Up Our Test Code Presented - - PDF document

W15 Test Automation Wednesday, October 2nd, 2019 2:45 PM What's That Smell? Tidying Up Our Test Code Presented by: Angie


slide-1
SLIDE 1

¡ ¡ W15 ¡

Test ¡Automation ¡ Wednesday, ¡October ¡2nd, ¡2019 ¡2:45 ¡PM ¡ ¡ ¡ ¡ ¡

What's ¡That ¡Smell? ¡Tidying ¡Up ¡Our ¡Test ¡ Code ¡ ¡

Presented ¡by: ¡ ¡ ¡

¡ Angie ¡ ¡Jones ¡

¡ Applitools ¡ ¡

Brought ¡to ¡you ¡by: ¡ ¡ ¡ ¡

¡ ¡ ¡ ¡

888-­‑-­‑-­‑268-­‑-­‑-­‑8770 ¡·√·√ ¡904-­‑-­‑-­‑278-­‑-­‑-­‑0524 ¡-­‑ ¡info@techwell.com ¡-­‑ ¡http://www.starwest.techwell.com/ ¡ ¡ ¡

¡

¡ ¡ ¡

slide-2
SLIDE 2

¡

Angie ¡ ¡Jones ¡

¡ Angie ¡Jones ¡is ¡a ¡Senior ¡Developer ¡Advocate ¡who ¡specializes ¡in ¡test ¡automation ¡ strategies ¡and ¡techniques. ¡She ¡shares ¡her ¡wealth ¡of ¡knowledge ¡by ¡speaking ¡and ¡ teaching ¡at ¡software ¡conferences ¡all ¡over ¡the ¡world, ¡as ¡well ¡as ¡writing ¡tutorials ¡and ¡ blogs ¡on ¡angiejones.tech. ¡As ¡a ¡Master ¡Inventor, ¡Angie ¡is ¡known ¡for ¡her ¡innovative ¡ and ¡out-­‑of-­‑the-­‑box ¡thinking ¡style ¡which ¡has ¡resulted ¡in ¡more ¡than ¡25 ¡patented ¡ inventions ¡in ¡the ¡US ¡and ¡China. ¡In ¡her ¡spare ¡time, ¡Angie ¡volunteers ¡with ¡Black ¡Girls ¡ Code ¡to ¡teach ¡coding ¡workshops ¡to ¡young ¡girls ¡in ¡an ¡effort ¡to ¡attract ¡more ¡women ¡ and ¡minorities ¡to ¡tech. ¡ ¡

slide-3
SLIDE 3

What's That Smell? What's That Smell?

Angie Jones Angie Jones

http://angiejones.tech http://angiejones.tech http://TestAutomationU.com http://TestAutomationU.com @techgirl1908 @techgirl1908 Senior Developer Advocate Senior Developer Advocate Director of Test Automation University Director of Test Automation University Applitools, San Francisco, CA, USA Applitools, San Francisco, CA, USA

Tidying Up Our Test Code Tidying Up Our Test Code

slide-4
SLIDE 4

@techgirl1908

slide-5
SLIDE 5

a CODE SMELL CODE SMELL is an implementation that is an implementation that violates fundamental design violates fundamental design principles in a way that may principles in a way that may slow down development and slow down development and increase the risk of future issues. increase the risk of future issues.

slide-6
SLIDE 6

APPLICATION APPLICATION UNDER UNDER TEST TEST

@techgirl1908

slide-7
SLIDE 7

JAKE'S JAKE'S CODE CODE BASE BASE

@techgirl1908

slide-8
SLIDE 8

@techgirl1908

LONG CLASS LONG CLASS The purpose of the class is The purpose of the class is multifold. multifold. To find anything, you must To find anything, you must scroll and scroll. scroll and scroll.

slide-9
SLIDE 9

ISSUES ISSUES

@techgirl1908

  • 1. No single responsibility
  • 1. No single responsibility
  • 2. Hard to find things
  • 2. Hard to find things
  • 3. Difficult to maintain
  • 3. Difficult to maintain
slide-10
SLIDE 10

@techgirl1908

SEPARATE SEPARATE CONCERNS CONCERNS

slide-11
SLIDE 11

@techgirl1908

LONG METHOD LONG METHOD This guy does it all! This guy does it all! But it makes it hard to know But it makes it hard to know when to call. when to call.

slide-12
SLIDE 12

ISSUES ISSUES

@techgirl1908

  • 1. No single responsibility
  • 1. No single responsibility
  • 2. Confusing for callers
  • 2. Confusing for callers
  • 3. Difficult to read and understand
  • 3. Difficult to read and understand
slide-13
SLIDE 13

@techgirl1908

SPLIT SPLIT METHODS METHODS

slide-14
SLIDE 14

@techgirl1908

DUPLICATE CODE DUPLICATE CODE When you find yourself When you find yourself coding in haste, coding in haste, it's very tempting it's very tempting to copy and paste. to copy and paste.

slide-15
SLIDE 15

ISSUES ISSUES

@techgirl1908

  • 1. Any change needed has to
  • 1. Any change needed has to

take place in multiple spots take place in multiple spots

  • 2. Can lead to other smells
  • 2. Can lead to other smells
slide-16
SLIDE 16

@techgirl1908

REMOVE REMOVE DUPLICATION DUPLICATION

slide-17
SLIDE 17

@techgirl1908

FLAKY LOCATOR STRATEGY FLAKY LOCATOR STRATEGY

At this moment, At this moment, your locators work fine. your locators work fine. But can they But can they stand the test of time? stand the test of time?

slide-18
SLIDE 18

ISSUES ISSUES

@techgirl1908

  • 1. Fragility
  • 1. Fragility
  • 2. Unreliability
  • 2. Unreliability
slide-19
SLIDE 19

@techgirl1908

STABILIZE STABILIZE LOCATORS LOCATORS

slide-20
SLIDE 20

@techgirl1908

INDECENT EXPOSURE INDECENT EXPOSURE

  • Too many see you.

Too many see you. Your scope is too wide. Your scope is too wide. All who should know you All who should know you

slide-21
SLIDE 21

ISSUES ISSUES

@techgirl1908

  • 1. Violates encapsulation
  • 1. Violates encapsulation
  • 2. Allows tests to directly access
  • 2. Allows tests to directly access

and manipulate the DOM, and manipulate the DOM, which is not their responsibility which is not their responsibility

slide-22
SLIDE 22

@techgirl1908

NARROW NARROW SCOPE SCOPE

slide-23
SLIDE 23

@techgirl1908

INEFFICIENT WAITS INEFFICIENT WAITS The speed of machine The speed of machine is faster than man is faster than man so you slow it down so you slow it down any way you can. any way you can.

slide-24
SLIDE 24

ISSUES ISSUES

@techgirl1908

  • 1. Slows down runtime
  • 1. Slows down runtime
  • 2. Different environments may
  • 2. Different environments may

require different wait times require different wait times

slide-25
SLIDE 25

@techgirl1908

WAIT WAIT INTELLIGENTLY INTELLIGENTLY

slide-26
SLIDE 26

@techgirl1908

MULTIPLE POINTS OF FAILURE MULTIPLE POINTS OF FAILURE

The framework's job The framework's job is to force state, is to force state, not to determine not to determine a test's fate. a test's fate.

slide-27
SLIDE 27

ISSUES ISSUES

@techgirl1908

  • 1. Violates single responsibility
  • 1. Violates single responsibility
  • 2. Limits reusuability
  • 2. Limits reusuability
slide-28
SLIDE 28

@techgirl1908

INCREASE INCREASE FLEXIBILITY FLEXIBILITY

slide-29
SLIDE 29

QUESTIONS? QUESTIONS?

@techgirl1908

slide-30
SLIDE 30

What's That Smell? What's That Smell?

Angie Jones Angie Jones

http://angiejones.tech http://angiejones.tech http://TestAutomationU.com http://TestAutomationU.com @techgirl1908 @techgirl1908 Senior Developer Advocate Senior Developer Advocate Director of Test Automation University Director of Test Automation University Applitools, San Francisco, CA, USA Applitools, San Francisco, CA, USA

Tidying Up Our Test Code Tidying Up Our Test Code