Continuous Testing and New Tools for Automation Using Selenium, Sauce Labs, GitHub, and Travis-CI **Presentation given at StarWest 2014
How I Spent My Summer Testing Continuous Testing on the Beach
What is Continuous Integration? “Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.” http://www.thoughtworks.com/continuous-integration
My Continuous Testing Process 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases 6. Run the tests 7. (Optionally) deploy code
Using GitHub for my Repo
My Continuous Testing Process 1. Commit and push
My Super Simple Demo App - Borrowed from Armin Ronacher Flaskr tutorial - https://github.com/mitsuhiko/flask/tree/master/examples/flaskr/
My Super Simple Demo App
GitHub and the .travis.yml file
Using Travis for my Builds
What is Travis-CI? “Travis-CI is a hosted, distributed continuous integration service used to build and test projects hosted at GitHub. Travis-CI automatically detects when a commit has been made and will try to build the project and run tests.” — http://en.wikipedia.org/wiki/Travis_CI
My Continuous Testing Process 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases
Simple .travis.yml example language: Python python: - 2.7 before_script: - lots of shell scripting here for setup for apache, etc. script: - flask --app=flaskr run &> flask.log &
Travis checks out the code…
Dependencies and DB Setup • Flask configuration and restart with document root and port • SQLite setup routines create the DB and CREATE TABLE • “pip install” runs to fetch and install various dependency packages
Using Selenium for my Tests Need help getting started with Selenium? Download the Selenium Bootcamp series here!
My Continuous Testing Process 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases 6. Run the tests
My Super Simple Test Case 1.Go to index page 2. Click Login link 3.Select Username text field element 4.Enter our username 5.Select Password text field element 6.Enter our password 7. Click login button
My Super Simple Test in Python 1.Go to index page 2. Click Login menu 3.Select Username text field element 4.Enter our username 5.Select Password text field element 6.Enter our password 7. Click login button
A Selenium server can be installed and run in the build env via .travis.yml
Using Sauce for our Test Runs Try Sauce for free, get an account here!
Running Tests on Sauce Sauce Connect is what enables the grid to run inside the Travis env
Configuring Travis for Sauce First, install the Travis gem locally: gem install travis Next, initialize your project for use with Travis CI: travis init We need to encrypt our credentials for safe use in GitHub: travis encrypt SAUCE_USERNAME=your_sauce_username --add travis encrypt SAUCE_ACCESS_KEY=XXXXXXXXXXXXXXXXX --add
.travis.yml example for Sauce Connect language: python python: - 2.7 env: global: - secure: HOTmOq6r+fjDDvr7gzETG7rS9IQtZ7QQ= - secure: NFM+4hE1VdaGs/lhaiVdn9Vi9P5L8Nb2t= addons: sauce_connect: true before_script: - lots of shell scripting here for apache, etc. script: - flask --app=flaskr run &> flask.log & - py.test -n4 --boxed example.py
My Continuous Testing Process 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases 6. Run the tests 7. (Optionally) deploy code
.travis.yml example for deployment language: python php: - 2.7 env: global: - secure: HOTmOq6r+fjDDvr7gzETG7rS9IQtZ7QQ= - secure: NFM+4hE1VdaGs/lhaiVdn9Vi9P5L8Nb2t= addons: sauce_connect: true before_script: - lots of shell scripting here for apache, etc. script: - flask --app=flaskr run &> flask.log & deploy: - your deployment instructions go here
Demo
Q&A

Continuous Testing and New Tools for Automation - Presentation from StarWest 2014

  • 1.
    Continuous Testing andNew Tools for Automation Using Selenium, Sauce Labs, GitHub, and Travis-CI **Presentation given at StarWest 2014
  • 2.
    How I SpentMy Summer Testing Continuous Testing on the Beach
  • 3.
    What is ContinuousIntegration? “Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.” http://www.thoughtworks.com/continuous-integration
  • 5.
    My Continuous TestingProcess 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases 6. Run the tests 7. (Optionally) deploy code
  • 6.
  • 7.
    My Continuous TestingProcess 1. Commit and push
  • 8.
    My Super SimpleDemo App - Borrowed from Armin Ronacher Flaskr tutorial - https://github.com/mitsuhiko/flask/tree/master/examples/flaskr/
  • 9.
  • 10.
    GitHub and the.travis.yml file
  • 11.
  • 12.
    What is Travis-CI? “Travis-CI is a hosted, distributed continuous integration service used to build and test projects hosted at GitHub. Travis-CI automatically detects when a commit has been made and will try to build the project and run tests.” — http://en.wikipedia.org/wiki/Travis_CI
  • 13.
    My Continuous TestingProcess 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases
  • 14.
    Simple .travis.yml example language: Python python: - 2.7 before_script: - lots of shell scripting here for setup for apache, etc. script: - flask --app=flaskr run &> flask.log &
  • 15.
    Travis checks outthe code…
  • 16.
    Dependencies and DBSetup • Flask configuration and restart with document root and port • SQLite setup routines create the DB and CREATE TABLE • “pip install” runs to fetch and install various dependency packages
  • 17.
    Using Selenium formy Tests Need help getting started with Selenium? Download the Selenium Bootcamp series here!
  • 18.
    My Continuous TestingProcess 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases 6. Run the tests
  • 19.
    My Super SimpleTest Case 1.Go to index page 2. Click Login link 3.Select Username text field element 4.Enter our username 5.Select Password text field element 6.Enter our password 7. Click login button
  • 20.
    My Super SimpleTest in Python 1.Go to index page 2. Click Login menu 3.Select Username text field element 4.Enter our username 5.Select Password text field element 6.Enter our password 7. Click login button
  • 21.
    A Selenium servercan be installed and run in the build env via .travis.yml
  • 22.
    Using Sauce forour Test Runs Try Sauce for free, get an account here!
  • 23.
    Running Tests onSauce Sauce Connect is what enables the grid to run inside the Travis env
  • 25.
    Configuring Travis forSauce First, install the Travis gem locally: gem install travis Next, initialize your project for use with Travis CI: travis init We need to encrypt our credentials for safe use in GitHub: travis encrypt SAUCE_USERNAME=your_sauce_username --add travis encrypt SAUCE_ACCESS_KEY=XXXXXXXXXXXXXXXXX --add
  • 26.
    .travis.yml example forSauce Connect language: python python: - 2.7 env: global: - secure: HOTmOq6r+fjDDvr7gzETG7rS9IQtZ7QQ= - secure: NFM+4hE1VdaGs/lhaiVdn9Vi9P5L8Nb2t= addons: sauce_connect: true before_script: - lots of shell scripting here for apache, etc. script: - flask --app=flaskr run &> flask.log & - py.test -n4 --boxed example.py
  • 27.
    My Continuous TestingProcess 1. Commit and push 2. Set up test server and env 3. Check out the code 4. Set up the test dependencies 5. Set up the test databases 6. Run the tests 7. (Optionally) deploy code
  • 28.
    .travis.yml example fordeployment language: python php: - 2.7 env: global: - secure: HOTmOq6r+fjDDvr7gzETG7rS9IQtZ7QQ= - secure: NFM+4hE1VdaGs/lhaiVdn9Vi9P5L8Nb2t= addons: sauce_connect: true before_script: - lots of shell scripting here for apache, etc. script: - flask --app=flaskr run &> flask.log & deploy: - your deployment instructions go here
  • 29.
  • 30.

Editor's Notes

  • #2  .
  • #3  .
  • #7  .
  • #12  .
  • #15  Why should customers care about out product? Sell the dream of a better future 1. Deliver a story or statement that arouses the audience’s interest Sauce Labs was founded 4 years ago by Jason Huggins (inventor of Selenium), Steve Hazel and John Dunham, with the goal of making testing awesome.   2. Pose a problem or question that has to be solved or answered Cross browser lab maintenance. How much time and money will it take you to setup and maintain on internal grid   3. Offer a solution to the problem you raised Sauce’s client cloud   4. Describe specific benefits for adopting the course of action set forth in your solution  Time sand money savings 5. State a call to action
  • #18  .
  • #23  .
  • #27  Why should customers care about out product? Sell the dream of a better future 1. Deliver a story or statement that arouses the audience’s interest Sauce Labs was founded 4 years ago by Jason Huggins (inventor of Selenium), Steve Hazel and John Dunham, with the goal of making testing awesome.   2. Pose a problem or question that has to be solved or answered Cross browser lab maintenance. How much time and money will it take you to setup and maintain on internal grid   3. Offer a solution to the problem you raised Sauce’s client cloud   4. Describe specific benefits for adopting the course of action set forth in your solution  Time sand money savings 5. State a call to action
  • #29  Why should customers care about out product? Sell the dream of a better future 1. Deliver a story or statement that arouses the audience’s interest Sauce Labs was founded 4 years ago by Jason Huggins (inventor of Selenium), Steve Hazel and John Dunham, with the goal of making testing awesome.   2. Pose a problem or question that has to be solved or answered Cross browser lab maintenance. How much time and money will it take you to setup and maintain on internal grid   3. Offer a solution to the problem you raised Sauce’s client cloud   4. Describe specific benefits for adopting the course of action set forth in your solution  Time sand money savings 5. State a call to action