How Does Your Code Smell?


(Jain) #1

I’ve been a software test automation engineer for quite a few years, and in that time, I’ve been asked to look at a lot of different automation. Early in my career, I learned about code smells the hard way. Now, I’ve been tasked with refactoring existing automation at a couple of different projects, and mentoring new automators to keep their code smelling fresh and clean.

Some of the things I’ve learned in my career are that you need to always give complete and meaningful exceptions when an automated task fails, that “assert(true)” is almost never the best way to give a meaningful failure, and that there is always, always a better way than using sleep().

I’ve also found that it’s best not to rely on your webdriver too heavily for automation. Lean on it only for the target behavior of your web application, and rely on backend services for repeatable tasks like data generation and even authentication.

What are some lessons that you’ve learned? What bad practices have you found to be common? How did you learn to do better? Please share your experiences below!