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.

How to make your functional tests really quick


Published on

Functional tests are usually the slowest layer of automated tests for almost every product. They use product via UI, store data in real DB, integrate with external services and do other “slow” things. The first easy answer how to make them fast is to run in parallel. But in reality tests depends on the same data and intersect by some common functionality. In this talk we will review useful techniques and approaches how to win this battle.

Published in: Technology

How to make your functional tests really quick

  1. 1. How to make your functional tests really quick Mikalai Alimenkou @xpinjection
  2. 2. Everybody likes Selenium Grid
  3. 3. WTF?!? But our tests depend on each other… 
  4. 4. Performance tips
  5. 5. Tip #1: Data independent tests • Most dependencies are data related • Dependent tests = no parallel execution • Data should be test specific with no reuse • Use small focused datasets
  6. 6. Test data generation techniques • Use Registry with counter to generate unique data • Fill database with large amount of data and use reservation • Use database sharding on application side • Shard data by unique key (user name, email, etc.) and insert data sets with DbUnit
  7. 7. Tip #2: Pool of resources • Manage browsers pool of needed size • Close browsers in background • Login in background before take a browser for test • Use direct sessions instead of login • Round robin technique between several nodes
  8. 8. Tip #3: Atomic focused tests • Small test has clear goal and easy to understand • Easy to divide in suites • Flexible running in multiple stages • Report failures are easier to understand • Run quickly so higher level of parallelization
  9. 9. Tip #4: Test only functionality • Don’t pay attention on design and content • Simplify everything except functionality under test • Run complex tests in reliable browsers
  10. 10. Tip #5: Generate app state • Insert data directly in data storage • Don’t use complex UI to generate state • Use small isolated datasets and simple tools
  11. 11. Tip #6: Test widgets in isolation • Create unit tests for JavaScript code • Load widget on empty page and test it well • Try to use reliable widgets library
  12. 12. Tip #7: Isolate all third-parties • Use quick fake email server • Mock all external services • Switch all third-party components in quick predictable mode • Run everything locally
  13. 13. Use HTTP proxy for tests • Blacklist external resources (Facebook, Twitter, Ads, etc.) • Cache images and other nonfunctional resources • Collect HTTP traffic for analysis (404, redirects, loading time, etc.) • Speedup page loading
  14. 14. Tip #8: Use smart waiting • Every delay is multiplied by number of tests • Don’t use speed and pauses at all • Use implicit waits carefully • Always think about the worst scenario and set good timeouts
  15. 15. Tip #9: Monitor your tests • Use CI server to gather time metrics • Check trends to select slow tests • Spend some time to improve them regularly • Set max allowed tests execution time and try to achieve it
  16. 16. @xpinjection