Treating test code as production code

Treating test code as production code
Writing Clean Test Code
Agenda
● What is Clean Code
● Demo App (AUT)
● Test Code
● Identify Code Smells
● Iteratively Refactor
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
Demo App
Home Search Results Book Details
Screens
Test Code
Problem:
No Single Responsibility
Problem: No Single Responsibility
● Can change for multiple reasons
● Poor readability and difficult to maintain
Page Object Model
Page Object Model
● Class that represents Page / UI
Component
● Methods in the class are services offered
by the Page / Component
Should Methods Return
Other Page Objects?
Pros of Returning Page Objects
● Method conveys correctly what changes
happened on UI
● Allows us to do method chaining
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
Problem:
Duplication of Locators
Problem: Duplication of Locators
● Can change for multiple reasons
● Difficult to maintain
Problem:
Missing Simplicity
Problem: Missing Simplicity
● Difficult to read and understand the
intent
Problem:
Duplication of Code
Problem: Unused Imports
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
Problem: Badly Named
Test Class
Problem: Badly Named Test Class
● Difficult to find tests
● Unrelated tests grouped together
Note on
Coding Styles & Linting
https://vocon-it.com/wp-content/uploads/2016/12/2016-12-28-15_49_04-main-html.png
Coding Style & Linting
Is Intent of Test
Getting Conveyed Clearly?
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
Test Code with Business Layer
Run Tests after
Small Logical Changes
Commit and Push
Small Changes
What more does it take to
write clean tests?
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
Thank you
@LavanyaMohan210
1 of 32

Recommended

Resume by
ResumeResume
ResumeMohammad shadab
322 views6 slides
BDD and Behave by
BDD and BehaveBDD and Behave
BDD and BehaveAdam Englander
1.4K views10 slides
Grading the Quality of Selenium Tests by
Grading the Quality of Selenium TestsGrading the Quality of Selenium Tests
Grading the Quality of Selenium TestsMarcus Merrell
1.6K views27 slides
What Is Cucumber? by
What Is Cucumber?What Is Cucumber?
What Is Cucumber?QATestLab
568 views8 slides
Everyday Functional Programming in JavaScript by
Everyday Functional Programming in JavaScriptEveryday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptLeo Hernandez
69 views20 slides
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing Tools by
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing ToolsHDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing Tools
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing ToolsJeff Bramwell
1.3K views16 slides

More Related Content

What's hot

Everyday Functional Programming in JavaScript by
Everyday Functional Programming in JavaScriptEveryday Functional Programming in JavaScript
Everyday Functional Programming in JavaScriptLeo Hernandez
75 views19 slides
Continuous improvements of developer efficiency with modern IDE by
Continuous improvements of developer efficiency with modern IDEContinuous improvements of developer efficiency with modern IDE
Continuous improvements of developer efficiency with modern IDEMikalai Alimenkou
1.3K views16 slides
BDD with SpecFlow and Selenium by
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumLiraz Shay
1.1K views55 slides
Testing Frameworks And Methodologies by
Testing Frameworks And MethodologiesTesting Frameworks And Methodologies
Testing Frameworks And MethodologiesSteven Cahill
7.4K views30 slides
Behavior Driven GUI Testing by
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI TestingAmanda Burma
698 views23 slides
Testing JavaScript Applications by
Testing JavaScript ApplicationsTesting JavaScript Applications
Testing JavaScript ApplicationsMuhammad Samu
213 views29 slides

What's hot(10)

Everyday Functional Programming in JavaScript by Leo Hernandez
Everyday Functional Programming in JavaScriptEveryday Functional Programming in JavaScript
Everyday Functional Programming in JavaScript
Leo Hernandez75 views
Continuous improvements of developer efficiency with modern IDE by Mikalai Alimenkou
Continuous improvements of developer efficiency with modern IDEContinuous improvements of developer efficiency with modern IDE
Continuous improvements of developer efficiency with modern IDE
Mikalai Alimenkou1.3K views
BDD with SpecFlow and Selenium by Liraz Shay
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
Liraz Shay1.1K views
Testing Frameworks And Methodologies by Steven Cahill
Testing Frameworks And MethodologiesTesting Frameworks And Methodologies
Testing Frameworks And Methodologies
Steven Cahill7.4K views
Behavior Driven GUI Testing by Amanda Burma
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI Testing
Amanda Burma698 views
Testing JavaScript Applications by Muhammad Samu
Testing JavaScript ApplicationsTesting JavaScript Applications
Testing JavaScript Applications
Muhammad Samu213 views
Final preso by Yilin Guo
Final presoFinal preso
Final preso
Yilin Guo224 views
Linways assessment codeways! by Bastin Thomas
Linways assessment  codeways!  Linways assessment  codeways!
Linways assessment codeways!
Bastin Thomas372 views

Similar to Treating test code as production code

Usable Software Design by
Usable Software DesignUsable Software Design
Usable Software DesignAlexandru Bolboaca
445 views83 slides
Automated UI testing done right (DDDSydney) by
Automated UI testing done right (DDDSydney)Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Mehdi Khalili
17.9K views143 slides
Automated UI Testing Done Right (QMSDNUG) by
Automated UI Testing Done Right (QMSDNUG)Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)Mehdi Khalili
2.5K views154 slides
Indy meetup#7 effective unit-testing-mule by
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleikram_ahamed
377 views31 slides
Unit testing (Exploring the other side as a tester) by
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Abhijeet Vaikar
38 views24 slides
Keeping code clean by
Keeping code cleanKeeping code clean
Keeping code cleanBrett Child
1.2K views54 slides

Similar to Treating test code as production code(20)

Automated UI testing done right (DDDSydney) by Mehdi Khalili
Automated UI testing done right (DDDSydney)Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)
Mehdi Khalili17.9K views
Automated UI Testing Done Right (QMSDNUG) by Mehdi Khalili
Automated UI Testing Done Right (QMSDNUG)Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)
Mehdi Khalili2.5K views
Indy meetup#7 effective unit-testing-mule by ikram_ahamed
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
ikram_ahamed377 views
Unit testing (Exploring the other side as a tester) by Abhijeet Vaikar
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
Abhijeet Vaikar38 views
Keeping code clean by Brett Child
Keeping code cleanKeeping code clean
Keeping code clean
Brett Child1.2K views
Software Testing Basic Concepts by wesovi
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
wesovi870 views
DrupalGov 2017: Testing any day: guide to end to end test driven Drupal projects by Vladimir Roudakov
DrupalGov 2017: Testing any day: guide to end to end test driven Drupal projectsDrupalGov 2017: Testing any day: guide to end to end test driven Drupal projects
DrupalGov 2017: Testing any day: guide to end to end test driven Drupal projects
Vladimir Roudakov353 views
How to establish ways of working that allows shifting-left of the automation ... by Max Barrass
How to establish ways of working that allows shifting-left of the automation ...How to establish ways of working that allows shifting-left of the automation ...
How to establish ways of working that allows shifting-left of the automation ...
Max Barrass95 views
End-end tests as first class citizens - SeleniumConf 2020 by Abhijeet Vaikar
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
Abhijeet Vaikar74 views
Magento applications and modules functional testing by Neklo
Magento applications and modules functional testingMagento applications and modules functional testing
Magento applications and modules functional testing
Neklo594 views
Designing for the internet - Page Objects for the Real World by Qualitest
Designing for the internet - Page Objects for the Real WorldDesigning for the internet - Page Objects for the Real World
Designing for the internet - Page Objects for the Real World
Qualitest676 views
May 2021 Spark Testing ... or how to farm reputation on StackOverflow by Adam Doyle
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
Adam Doyle82 views
CookpadTechConf2018-(Mobile)TestAutomation by Kazuaki Matsuo
CookpadTechConf2018-(Mobile)TestAutomationCookpadTechConf2018-(Mobile)TestAutomation
CookpadTechConf2018-(Mobile)TestAutomation
Kazuaki Matsuo3.1K views
Automation Testing on Selenium by Quontra Solutions by QUONTRASOLUTIONS
Automation Testing on Selenium by Quontra SolutionsAutomation Testing on Selenium by Quontra Solutions
Automation Testing on Selenium by Quontra Solutions
QUONTRASOLUTIONS928 views
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman by QA or the Highway
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
QA or the Highway353 views

Recently uploaded

Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
180 views18 slides
Business Analyst Series 2023 - Week 4 Session 8 by
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8DianaGray10
123 views13 slides
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
147 views23 slides
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...ShapeBlue
173 views15 slides
The Power of Heat Decarbonisation Plans in the Built Environment by
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
79 views20 slides
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsShapeBlue
238 views13 slides

Recently uploaded(20)

Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue180 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10123 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue147 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue173 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE79 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue238 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue139 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue180 views
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ by ShapeBlue
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
ShapeBlue130 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty64 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue221 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue198 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue119 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue126 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue222 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li85 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue252 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue194 views

Treating test code as production code