Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PyCon Ukraine 2014

1,897 views

Published on

We live in changeable world, and our applications are also very inconstant. As a result we have to know how to improve project quality. The subject of my presentation is related to the modern approaches of designing and implementing automated functional tests, by using, for instance, design patterns, improving test execution time based parallel execution, scaling by distributing tests on several machines, creating strategy for generation of big sets of test data and setup skeleton for organizing tests for typical Django project. I am pleased to share with you my acquired experience in this field.

Published in: Internet
  • Be the first to comment

PyCon Ukraine 2014

  1. 1. AUTOMATED FUNCTIONAL TESTS BASED ON SELENIUM FOR DJANGO PROJECTS ANDRII SOLDATENKO
  2. 2. ABOUT ME: • TEST  AUTOMATION  LEAD  AT  LUXOFT   • PYTHON  DEVELOPER  AT  TOPTAL   • @A_SOLDATENKO   • HTTP://ANDRIISOLDATENKO.GITHUB.IO/
  3. 3. “TESTS ARE THE PROGRAMMER’S STONE, TRANSMUTING FEAR INTO BOREDOM.” - KENT BECK 3 WE DON’T HAVE TIME FOR TESTS!
  4. 4. TEST AUTOMATION PYRAMID: Unit tests Integration tests Functional tests
  5. 5. TASK: HOW TO AUTOMATE FUNCTIONAL TESTS FOR WEB?
  6. 6. ABOUT SELENIUM: • PIP  INSTALL  -­‐U  SELENIUM • SELENIUM  WEBDRIVER  API  NOW  IN  W3C  DRAFT  SPECIFICATION • RUN  IN  MANY  BROWSERS • AND  OS • CAN  BE  CONTROLLED  BY  DIFFERENT  PROGRAMMING  LANGUAGES
  7. 7. 7 DEMO
  8. 8. WHEN  NUMBER  OF  TESTS  IS  GROWING: • WE  NEED  TO  DECREASE  TEST  EXECUTION  TIME • WE  NEED  TO  USE  DESIGN  PATTERNS  (I.E  PAGEOBJECT,  PAGEFACTORY) • WE  NEED  TO  USE  SKELETON  FOR  ORGANIZING  TESTS
  9. 9. SKELETON  FOR  ORGANIZING  TESTS:
  10. 10. DESIGN  PATTERNS:
  11. 11. SIMPLE  SELENIUM  TEST  WITHOUT  PAGEOBJECT:
  12. 12. SIMPLE  SELENIUM  TEST  WITH  PAGEOBJECT:
  13. 13. SIMPLE  SELENIUM  TEST  WITH  PAGEOBJECT:
  14. 14. SIMPLE  SELENIUM  TEST  WITH  PAGEOBJECT:
  15. 15. WHAT  ABOUT  FT  IN  DJANGO?
  16. 16. HOW  TO  DECREASE  TEST  EXECUTION  TIME  ? • SET  UP  LOCAL  SELENIUM  GRID • USE  SAUCE  LABS • USE  PYTEST  OR  NOSE
  17. 17. ABOUT  SELENIUM  GRID: Node Node Node Hub
  18. 18. SETUP  SELENIUM  GRID  LOCALLY:
  19. 19. SCHEME  FOR  SELENIUM  GRID  +  CONCURRENT  TEST  EXECUTION py.test unittest.TestCase Node Node Node Hub
  20. 20. BEST  PRACTICE  FOR  TEST  DATA  GENERATION  AND   • DJANGO  LOREM  IPSUM  UTILS   • DON’T  USE  FIXTURES   • USE  FACTORY  BOY  +  FAKER  INSTEAD  OF  FIXTURES
  21. 21. BEST  PRACTICE  FOR  CREATION  FT  TESTS: • USE  EXPLICIT  WAITS  RATHER  THAN  IMPLICIT  WAITS.   • USE  CODE—HELPER  METHODS  IN  BASE  CLASS,  OR  PAGE  PATTERN. • AVOID  DOUBLE-­‐TESTING  FUNCTIONALITY • LOOK  INTO  BDD  TOOLS • USE  CONTINUOUS  INTEGRATION
  22. 22. 22 ? QUESTIONS:
  23. 23. 23 • @A_SOLDATENKO   • HTTPS://ANDRIISOLDATENKO.GITHUB.IO/ THANK  YOU:

×