This document provides an overview of a training on test automation. It outlines a 4 stage approach to test automation:
1) Stage 1 involves writing basic scripts to test a site without using page objects or a testing framework.
2) Stage 2 introduces Cucumber for writing tests in a plain English format without code.
3) Stage 3 focuses on writing specifications that can be used across multiple platforms and applications.
4) Stage 4 covers implementing page objects to hide browser interactions and provide a more intuitive task-based testing interface.
The training covers each stage through demonstrations and exercises with the goal of helping attendees better understand common mistakes and approaches to test automation.
Four Stages of Automated Testing by Bradley Temple
1. 4 Stages of Test
Automation
Welcome to your first day at fake-amazon.com
2. Expectations
• We will move quickly, as there is a lot of content and 3
and a half hours will go much faster than we think it will
• The virtual machine thing was the best I could do without
having time to work with anyone ahead of time, as setting
up a working dev environment is non-trivial, if you
couldn’t get it going, pair up with someone who did
• If you have something in particular you are hoping to get
out of the class, put it up on the class backlog and I will
try and get to it.
3. Expectations
• You’ll get some time to try each stage on your own or in a
pair before we go over it as a class. Ideally you’d get a
couple hours to experiment with each stage, but we’re
running on a compressed timeframe.
• You won’t be an expert when you leave today, but you’ll
hopefully have a better idea of what the mistakes you’ll
make along the way look like so you can move past them
easier.
4. Agenda
• 8-8:15 - Working Agreements, Class Backlog
• 8:15-8:45 -Automation Crash Course (New Hire Training)
• 8:45 - 9:15 - Stage 1 - A basic Test
• 9:15 - 9:30 Class Walkthrough of Stage 1
• 9:30 - 10 Stage 2 - Cucumber
• 10-10:15 Class Walkthrough of Stage 2
• 10:15-10:45 Stage 3 - Gherkin as a Specification
• 10:45 - 11 Class Walkthrough of Stage 3
• 11-11:15 Class Walkthrough of Stage 4
• 11:15-11:30 - Questions and Answers
22. So you’re the new hires? Great. Fantastic.
We’re trying to ship our new feature. Hold
onto your hats, we’re gonna ship everything
for FREE on orders worth more than $35.
23. We need some tests around it but manually
adding stuff to the cart is taking too long.
So you’re the new hires? Great. Fantastic.
24. I heard you know how to automate
websites, so if you can make that happen,
it’d be great.
So you’re the new hires? Great. Fantastic.
27. How to do it
• Your script is in the script directory.
• You can run it by executing bin/run-test
• If things stop working, run bin/bootstrap again
• I’ll be walking around, if you need help, ask
28. Things we should do in our
script
• Log In (student@example.com / supersecret)
• Add a cheap item to the cart
• Visit the checkout page
• Add an expensive item to the cart
• Navigate to the checkout page
• Complete checkout
29. Problems with this
approach
• Relies on ‘known data’
• Can’t be re-run (application state is changed as a result of
the test run)
• Doesn’t actually test anything
• Lots of repetition
• Tied to UI Details
• Not clear what the feature being tested is
30. So I went to a conference last week…
Hey that script you wrote is great, just
great. But everyone was talking about this
cucumber thing, have you heard of it?
31. So I went to a conference last week…
You can just write your tests in english and
you don’t need any of that code stuff, since
no one knows what that does anyway.
32. So I went to a conference last week…
How about we redo it with the Cucumber?
34. So I was chatting with the devs…
Everyone loves what you’re doing with the
testing stuff
35. Except the devs, of course , they hate it.
So I was chatting with the devs…
36. They’re trying to use the specification for
the mobile app, but it super doesn’t work.
Can we make it just, like, general?
So I was chatting with the devs…
38. Hey, that spec is great. We’re gonna use it
on the mobile app too.
So about those breaking tests
39. But tests are still breaking when some stuff
changes. The dev said you can do some
kinda object doohickey to fix it. Maybe pair
with them on it?
So about those breaking tests
40. Object Oriented Programming
(A hasty primer)
• Objects
• Receive Messages and produce Behavior
• click_link is a message that invokes the behavior of clicking an <a>
tag
• Is a model of a thing or idea in the real world
• Hide moving parts behind a particular interface (Encapsulation)
• Allow different objects to receive the same message but respond
differently (Polymorphism)
• Can gain behavior from a parent (Inheritance)
41. Object Oriented Programming
(A hasty primer)
• Classes
• Define a thing
• Person is a Class
• Instances
• A specific thing based on the definition (proper noun)
• Bradley is an instance of Person
42. Object Oriented Programming
(A hasty primer)
class Person
attr_reader :name,
:bmi,
:blood_pressure,
:pulse,
:last_slept_at,
:support_network,
:hunger_level,
:personal_sense_of_satisfaction,
:insecurities
def how_are_you_feeling?; end
end
43. Object Oriented Programming
(A hasty primer)
person = Person.new(“Bradley”, *other_attributes)
person.how_are_you_feeling?
# => “Fine”
44. Object Oriented Programming
(A hasty primer)
class Tester < Person
def how_are_you_feeling?
process_last_interaction_with_a_developer()
super()
end
end
45. Object Oriented Programming
(A hasty primer)
person = Tester.new(“Bradley”, *other_attributes)
person.how_are_you_feeling?
# => “Irritated”
46. Page Object
• Up till now we’ve been sending message directly to an
object controlling the browser, so all of our test code is
written in terms of low-level detail of browser interaction
• People do not think about whether something is a button
or a link, people think about tasks that they want to
complete on a page.
• A page object provides a way to hide away the details of
browser interaction behind a more intuitive task-based
message interface