Top Banner
T3 Test Automation 5/8/2014 9:45:00 AM Patterns of Automation: Simplify Your Test Code Presented by: Jeff Morgan LeanDog Brought to you by: 340 Corporate Way, Suite 300, Orange Park, FL 32073 888-268-8770 ∙ 904-278-0524 ∙ [email protected] ∙ www.sqe.com
101

Patterns of Automation: Simplify Your Test Code

May 11, 2015

Download

Technology

Many organizations are introducing test automation only to discover it is more difficult than they anticipated. The fact is that good test automation requires good coding practices. Good test automation requires good design. To do anything else will lead to spaghetti code that is hard to maintain or update. If you’re new to coding or new to automation, it is difficult to know where to begin. Join Cheezy as he describes and demonstrates lessons he has learned while helping numerous organizations adopt test automation. Cheezy shows the patterns he uses to keep automation code simple and clean, and demonstrates techniques you can use to make your automation code more maintainable. Finally, Cheezy writes code (without a net) to implement these patterns, taking them from theory to implementation.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Patterns of Automation: Simplify Your Test Code

T3

Test Automation

5/8/2014 9:45:00 AM

Patterns of Automation: Simplify

Your Test Code

Presented by:

Jeff Morgan

LeanDog

Brought to you by:

340 Corporate Way, Suite 300, Orange Park, FL 32073

888-268-8770 ∙ 904-278-0524 ∙ [email protected] ∙ www.sqe.com

Page 2: Patterns of Automation: Simplify Your Test Code

Jeff Morgan

LeanDog

Chief technology officer and a cofounder of LeanDog, Jeff “Cheezy” Morgan has been teaching classes and coaching teams on agile and lean techniques since early 2004. Most of his work has focused on the engineering practices used by developers and testers. For the past few years Cheezy has experienced great success and recognition for his work focused on helping teams adopt Acceptance Test Driven Development using Cucumber. He has authored several popular Ruby gems used by software testers and the book Cucumber & Cheese-A Testers Workshop.

Page 3: Patterns of Automation: Simplify Your Test Code

Patterns of Automation

Jeff “Cheezy” Morgan @chzy

[email protected]

Page 4: Patterns of Automation: Simplify Your Test Code

Copyright 2012 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Life is good

Page 5: Patterns of Automation: Simplify Your Test Code

Why Automate?

Page 6: Patterns of Automation: Simplify Your Test Code
Page 7: Patterns of Automation: Simplify Your Test Code
Page 8: Patterns of Automation: Simplify Your Test Code
Page 9: Patterns of Automation: Simplify Your Test Code
Page 10: Patterns of Automation: Simplify Your Test Code
Page 11: Patterns of Automation: Simplify Your Test Code

Manual Testing (not ET)

1

Page 12: Patterns of Automation: Simplify Your Test Code

Manual Testing (not ET)

11.5

Page 13: Patterns of Automation: Simplify Your Test Code

Manual Testing (not ET)

11.5

2.2

Page 14: Patterns of Automation: Simplify Your Test Code

Manual Testing (not ET)

11.5

2.23.0

4.0

5.36.4

Page 15: Patterns of Automation: Simplify Your Test Code

Test What?

Page 16: Patterns of Automation: Simplify Your Test Code

Test What?• Functionality

Page 17: Patterns of Automation: Simplify Your Test Code

Test What?• Functionality

• Cross-Browser

Page 18: Patterns of Automation: Simplify Your Test Code

Test What?• Functionality

• Cross-Browser

• Responsive Design

Page 19: Patterns of Automation: Simplify Your Test Code

Test What?• Functionality

• Cross-Browser

• Responsive Design

• Mobile Devices

Page 20: Patterns of Automation: Simplify Your Test Code

Test What?• Functionality

• Cross-Browser

• Responsive Design

• Mobile Devices

• Security

Page 21: Patterns of Automation: Simplify Your Test Code

Test What?• Functionality

• Cross-Browser

• Responsive Design

• Mobile Devices

• Security

• Accessibility

Page 22: Patterns of Automation: Simplify Your Test Code

Test What?• Functionality

• Cross-Browser

• Responsive Design

• Mobile Devices

• Security

• Accessibility

• Load and Performance

Page 23: Patterns of Automation: Simplify Your Test Code

Allows time to Explore• Functionality

• Cross-Browser

• Responsive Design

• Mobile Devices

• Security

• Accessibility

• Load and Performance

Page 24: Patterns of Automation: Simplify Your Test Code

What are Patterns?

Page 25: Patterns of Automation: Simplify Your Test Code

Pattern

A pattern, apart from the term's use to mean "Template"[a], is a discernible regularity in the world or in a manmade design. As such, the elements of a pattern repeat in a predictable manner.! - Wikipedia

Page 26: Patterns of Automation: Simplify Your Test Code

Specification by Example

Page 27: Patterns of Automation: Simplify Your Test Code

Development Artifacts

User Story with

Acceptance Criteria

Code with Unit Tests

Automated Tests

Specification Implementation Verification

Page 28: Patterns of Automation: Simplify Your Test Code

Development Artifacts

User Story with

Acceptance Criteria

Code with Unit Tests

Automated Tests

Specification Implementation Verification

Duplication

Page 29: Patterns of Automation: Simplify Your Test Code
Page 30: Patterns of Automation: Simplify Your Test Code

Difference between requirement and test

is data!

Page 31: Patterns of Automation: Simplify Your Test Code

Addition Function

Page 32: Patterns of Automation: Simplify Your Test Code

Addition Function

Requirement: Addition equals

sum of numbers

Page 33: Patterns of Automation: Simplify Your Test Code

Addition Function

Requirement: Addition equals

sum of numbers

Examples: 3 + 4 = 7 3 + -1 = 2

etc.

Page 34: Patterns of Automation: Simplify Your Test Code

Let’s see it!

Page 35: Patterns of Automation: Simplify Your Test Code

Did you notice I never said click or enter text?

Page 36: Patterns of Automation: Simplify Your Test Code

Acceptance Test Driven Development

Page 37: Patterns of Automation: Simplify Your Test Code

ReworkCode Test

Story 1

Page 38: Patterns of Automation: Simplify Your Test Code

ReworkCode Test

Code Test

Story 1

Story 2

Page 39: Patterns of Automation: Simplify Your Test Code

ReworkCode Test

Story 1

Story 2

CStory 1

Test

Code TestStory 2

C

Page 40: Patterns of Automation: Simplify Your Test Code

ReworkCode Test

Story 1

Story 2

CStory 1

TestStory 2

C

CStory 1

Test

Code TestStory 2

C

Page 41: Patterns of Automation: Simplify Your Test Code
Page 42: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Test Review Done

Product Owner

Developer Tester

Page 43: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Test Review Done

Product Owner

Developer Tester

Page 44: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Test Review Done

Product Owner

Developer Tester

Page 45: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Test Review Done

Product Owner

Developer Tester

Page 46: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Test Review Done

Product Owner

Developer Tester

Page 47: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 48: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 49: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 50: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 51: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 52: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

?

Page 53: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 54: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 55: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Page 56: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Done

Page 57: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Done

Page 58: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Ready Development Review Done

Product Owner

Developer Tester

Done Done

Page 59: Patterns of Automation: Simplify Your Test Code

Code Test

Page 60: Patterns of Automation: Simplify Your Test Code

CodeTest

Page 61: Patterns of Automation: Simplify Your Test Code

CodeTest

Developer

Tester

Page 62: Patterns of Automation: Simplify Your Test Code

Test Drive Code With PairCodeTest

Developer

Tester

Page 63: Patterns of Automation: Simplify Your Test Code

Test Drive Code With Pair

CodeTest

Developer

Tester

Page 64: Patterns of Automation: Simplify Your Test Code

Test Drive Code With Pair

Automate Acceptance TestsCodeTest

Developer

Tester

Page 65: Patterns of Automation: Simplify Your Test Code

Test Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Page 66: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests Pass

Test Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Page 67: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests PassTest Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Page 68: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests PassTest Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Exploratory Testing

Page 69: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests PassTest Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Exploratory Testing

Page 70: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests Pass

Talk

Test Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Exploratory Testing

Page 71: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests Pass

Talk

Test Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Exploratory Testing

Page 72: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests Pass

TalkPrevent Defects

Test Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Exploratory Testing

Page 73: Patterns of Automation: Simplify Your Test Code

Make Acceptance Tests Pass

Talk Prevent Defects

Test Drive Code With Pair

Automate Acceptance Tests

CodeTest

Developer

Tester

Exploratory Testing

Page 74: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Creation Elaboration Validation WIP

Product Owner

Page 75: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Creation Elaboration Validation WIP

Product Owner

Tester

Page 76: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Creation Elaboration Validation WIP

Product Owner

Tester

Developer

Page 77: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Creation Elaboration Validation WIP

Product Owner

Tester

Developer

Page 78: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

Creation Elaboration Validation WIP

Product Owner

Tester

Developer

Progressive

Elaboration

Page 79: Patterns of Automation: Simplify Your Test Code

Page Object

Page 80: Patterns of Automation: Simplify Your Test Code
Page 81: Patterns of Automation: Simplify Your Test Code

Tests break when application changes

!

How easy to fix?

Page 82: Patterns of Automation: Simplify Your Test Code

Learn from the development community

Page 83: Patterns of Automation: Simplify Your Test Code

Learn from the development community

Page 84: Patterns of Automation: Simplify Your Test Code

Let’s see it!

Page 85: Patterns of Automation: Simplify Your Test Code

Default Data

Page 86: Patterns of Automation: Simplify Your Test Code

A lot of Data

Page 87: Patterns of Automation: Simplify Your Test Code

A lot of Data

Sorry Data, I don’t care about most of you!

Page 88: Patterns of Automation: Simplify Your Test Code

Let’s see it!

Page 89: Patterns of Automation: Simplify Your Test Code

Test Data Management

Page 90: Patterns of Automation: Simplify Your Test Code

Why did you tests fail? Did somebody mess with your data?

Page 91: Patterns of Automation: Simplify Your Test Code

Test beginsInsert data needed for

this testTest

executesTest removes

data

BestRepeat for next test

Page 92: Patterns of Automation: Simplify Your Test Code

Test beginsInsert data needed for

this testTest

executesTest removes

data

BestRepeat for next test

Another optionInsert all

data necessary for all tests

Execute all tests

Remove all data

Page 93: Patterns of Automation: Simplify Your Test Code

Test beginsInsert data needed for

this testTest

executesTest removes

data

BestRepeat for next test

Another optionInsert all

data necessary for all tests

Execute all tests

Remove all data

Yet another optionRecondition data from last test

execution

Execute all tests

Page 94: Patterns of Automation: Simplify Your Test Code

Do not repeat dataDo not repeat data

Do not repeat dataDo not repeat data

Do not repeat dataDo not repeat dataDo not repeat data

Page 95: Patterns of Automation: Simplify Your Test Code

Route Navigation

Page 96: Patterns of Automation: Simplify Your Test Code

Navigating routes is something we do all the time

Page 97: Patterns of Automation: Simplify Your Test Code

Let’s see it!

Page 98: Patterns of Automation: Simplify Your Test Code

Above All

Keep the code clean

Page 99: Patterns of Automation: Simplify Your Test Code

And

Page 100: Patterns of Automation: Simplify Your Test Code

Do not Automate too much!

Page 101: Patterns of Automation: Simplify Your Test Code

Copyright 2013 LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.

[email protected] @chzy

Thank You