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.

0

Share

Download to read offline

Treating test code as production code

Download to read offline

Slides from the TribalQonf talk (2020)

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Treating test code as production code

  1. 1. Writing Clean Test Code
  2. 2. Agenda ● What is Clean Code ● Demo App (AUT) ● Test Code ● Identify Code Smells ● Iteratively Refactor
  3. 3. Clean Code “Clean code is simple and direct. Clean code reads like well-written prose.” - Grady Booch Mentioned in Book “Clean Code: A Handbook of Agile Software Craftsmanship” by Robert C. Martin
  4. 4. Demo App
  5. 5. Home Search Results Book Details Screens
  6. 6. Test Code
  7. 7. Problem: No Single Responsibility
  8. 8. Problem: No Single Responsibility ● Can change for multiple reasons ● Poor readability and difficult to maintain
  9. 9. Page Object Model
  10. 10. Page Object Model ● Class that represents Page / UI Component ● Methods in the class are services offered by the Page / Component
  11. 11. Should Methods Return Other Page Objects?
  12. 12. Pros of Returning Page Objects ● Method conveys correctly what changes happened on UI ● Allows us to do method chaining
  13. 13. Cons of Returning Page Objects ● Pages are tightly coupled ● Special handling is required if same function have to return different pages ● Duplication of this information as it is present in both test and page Page Objects: You're Doing It Wrong by Titus Fortner - https://www.youtube.com/watch?v=vg8um4bYQXI
  14. 14. Problem: Duplication of Locators
  15. 15. Problem: Duplication of Locators ● Can change for multiple reasons ● Difficult to maintain
  16. 16. Problem: Missing Simplicity
  17. 17. Problem: Missing Simplicity ● Difficult to read and understand the intent
  18. 18. Problem: Duplication of Code
  19. 19. Problem: Unused Imports
  20. 20. Problem: Unused Imports ● Causes clutter in the code ● Shows up during search and gives an incorrect indication that it is being used in the class
  21. 21. Problem: Badly Named Test Class
  22. 22. Problem: Badly Named Test Class ● Difficult to find tests ● Unrelated tests grouped together
  23. 23. Note on Coding Styles & Linting
  24. 24. https://vocon-it.com/wp-content/uploads/2016/12/2016-12-28-15_49_04-main-html.png Coding Style & Linting
  25. 25. Is Intent of Test Getting Conveyed Clearly?
  26. 26. Business Layer Tests Pages Tests Business Layer Pages Patterns of a “good” Test Automation Framework by Anand Bagmar - https://www.youtube.com/watch?v=mNSJuVVq26I
  27. 27. Test Code with Business Layer
  28. 28. Run Tests after Small Logical Changes Commit and Push Small Changes
  29. 29. What more does it take to write clean tests?
  30. 30. Test Code - https://github.com/bitweft/book_information_e2e_tests Book Information Demo App Code (which includes Espresso tests demo) - https://github.com/bitweft/book_information_espresso_demo Clean Code book by Robert C Martin - https://www.amazon.in/Clean-Code- Robert-C-Martin/dp/8131773388 Page Objects: You're Doing It Wrong by Titus Fortner - https://www.youtube.com/watch?v=vg8um4bYQXI Patterns of a “good” Test Automation Framework by Anand Bagmar - https://www.youtube.com/watch?v=mNSJuVVq26I References & Links
  31. 31. Thank you @LavanyaMohan210

Slides from the TribalQonf talk (2020)

Views

Total views

76

On Slideshare

0

From embeds

0

Number of embeds

0

Actions

Downloads

0

Shares

0

Comments

0

Likes

0

×