4. Really though, who are you?
• Came from Java world
• Python developer for 2 years
• DevOps
– Lots of work with automation and quality
• First introduced to AAT about 2 years ago
– Now I use it at my client!
7. • Go to the website, click around, make sure
things look right…
• Problem: Scaling
– What happens as the site continues to grow?
– What happens as we deploy more frequently?
• We need a way to test the functionality of
the site
Simple!
9. • Tests written at the functional/business
level
• Can be read by non-technical people
• Doesn’t have to be automated to provide
value!!!
What is Acceptance Testing
16. • Java/JVM world: Cucumber-JVM/JBehave
• Ruby: Cucumber-Ruby
• Ruby on Rails: Cucmber-Rails
• Node.js/Javascript: Cucumber-Javascript
– AngularJS: Protractor not the same
• C#/.NET: SpecFlow
• Python: Behave
Cucumber
16
17. • Cucumber’s syntax and style is virtually
the same across all the platforms!
• Tonight’s examples will be in Python
Good News Everyone…
17
18. • One example, from start to finish
– This is how we solve problems
• Learning Objectives:
– Write an acceptance test
– Automate that test using Selenium
– Incorporate that test into your Continuous
Integration
• Stay high level
– Not enough time to go deep
Let’s get started!
18
25. • A Human-readable syntax describing the
test
• Consists of a main “feature” and scenarios
describing the feature
Writing Gherkin
26. Feature: Title (one line describing the story/feature)
As a [role]
I want [feature]
So that [benefit]
Scenario: Title1 (for Behaviour 1)
Given [context or setup]
And [some more context]...
When [event occurs]
Then [expected outcome]
And [another outcome]...
Scenario: Title2 (for Behaviour 2)
…
Writing Gherkin
26
28. • Value even when not automated
– Clear, concise way to manually test
– Developer friendly
• Not extremely specific…
– What does it mean “a new cat image should
be loaded…”?
– Declarative vs Imperative
– Don’t get bogged down in
precision/verboseness
Observations
31. • Create an “environment.py” file in the
features directory
– Defines the test runner setup
• (optional) Create an environment.cfg file in
the features directory
– Holds editable configurations for your setup
• Create a “steps.py” file in the steps directory
– Contains the implementation of your steps
Project Setup
31
33. • Setting up Selenium
– Select a driver, like Chromedriver, PhantomJS
or SauceLabs
• Setting up a logger
• Initializing the context object
• Set defaults
What goes in Environment.py?
33
34. • Parses each line of Gherkin
• Decide how to implement
Glue code (steps)
home.feature
steps/steps.py
36. • Making references to context
– Way of passing information between steps
• What is “Home” in the context?
– Class representing the homepage
– Part of “Page-object model”
Observations
36
45. • Need to setup the web driver
– Let’s use ChromeDriver
• https://sites.google.com/a/chromium.org/chromedri
ver/getting-started
Environment.py revisited
45
49. • Now that we have tests
– Validate site is up and running
– Validate deployments
– Ensure new code doesn’t break existing
functionality (regression)
Why Continuous Integration?
51. • PhantomJS
– Headless browser
– Based on Webkit
– Fast
• Works with Selenium
Solving the problem
51
52. • Black Box
– Can’t see problems when they happen
• Can’t handle certain things
– e.g. alerts
• Buggy, but getting better
Problems with PhantomJS
52
At this time, I don’t recommend it…
54. • Test different browser / os configurations
– Don’t need to own that hardware
• Integration with many CI tools
– Jenkins, Travis, CircleCI, Bamboo, Teamcity…
• Video recording/playback
– No longer a black box!!!
Advantages
54
58. • Sign Up for an account:
– https://saucelabs.com/signup/trial
• Receive an API key
Sauce Labs Setup
59. • Modify your environment.py file to use
Sauce instead of Chrome
– Provide username and api key
– Select a browser and OS to use
Sauce Labs Setup
59
64. • Can only test what’s available through the
browser
• Selenium can be painful at times
– May not wait for things to load
– Debugging can be hard
Limitations of AAT
65. • Data
– Not a great choice for data-heavy applications
– Not impossible, but trickier:
• Launch a separate test server?
• Create a “testing mode” where transactions are
rolled back
– Might be better covered by Integration Testing
Limitations of AAT
65