# 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**


/page
**LoginPage class**

/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

## Allow codes to run the test across devices
Smells solutions
```
if ("Android") ...
else if ("IOS") ...
else if ("web") ...
```
## Further reading - Persona-Based Testing
https://smartbear.com/blog/personas-based-testing/
https://medium.com/@ChamalAsela/persona-based-testing-de6e1396c23c
###### tags: `learn` `test automation`