Clean Coding Practices for Test Automation -LambdaTest INC 20220913
Source
https://www.youtube.com/c/LambdaTest/featured
Code smells examples
- Sleep instead of Wait
- Poor variable naming
- Repetitive codes
- Try Catch with an empty catch
- Single class with all helper functions
- Harding credentials
Project structure after code refactoring
/driver
DriverManager class
/personas (domain-specific, different tasks that different users can do)
Actor class (abstract class, has basic functions for different actions like login
, writePost
, readNotification
)
Admin class (extends Actor)
Author class (extends Actor)
/flow
FlowFactory class (use DeviceInterface)
Android class (extends DeviceInterface)
IOS class (extends DeviceInterface)
DeviceInterface class
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
/page
LoginPage class
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
/test
WordpressTest class (implement tests)
Principles that help codes better
-
Clean code
-
Design principles
- Single-responsibility principle (SRP)
- Open CLosed Principle
Look at things from domain perspectives
From domain perspectives and find out the corresponding design principles that can be used.
BaseTest class
- All test class extends the BaseTest class
- The BaseTest class defines steps of before suite, before each, and other shared functions that are used in all test classes
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Allow codes to run the test across devices
Smells solutions
Further reading - Persona-Based Testing
https://smartbear.com/blog/personas-based-testing/
https://medium.com/@ChamalAsela/persona-based-testing-de6e1396c23c