Common Pitfalls When Automating Your Tests

pitfall

We’ve all experienced it – writing our first tests is a great feeling and brings much joy to our hearts. It’s an exciting step in a new direction. Then we write some more tests and the suite grows bigger and slower. A couple of months later, some business requirement has changed or the design and dev team redesigned some functionality and our tests are now causing more trouble than helping the project. Here are few things to watch out for, in order to handle these scenarios more painlessly:

 

1.Be careful with the record button

recordbutton

The problem: Recording your manual tests speeds up the process of automation… until something changes. Also the tools for “play”-ing the records are not incredibly fast and the execution time of your suite quickly raises.

The solution:

  • Do not count on the recorded scripts to do your job – Use them as a skeleton for your test and make them maintainable. Separate them into modules that can be easily replaced and worked on by multiple people.
  • Parameterize your queries – This is especially true in a system where the UI is generated. Do not expect something like “/div/p/div[1]/button” to be working until the end of the world.

 

2.Ignoring good development practices

The problem: Newsflash – test automation is development. Yep. You are a developer now. Among many other things, this means that you now need to follow the good practices of development or you will be in the mud faster than you think. Copy/pasting does not work in the long run. You need modules in order for multiple team members to work on the same test.

The solution: Take your time and learn/ask the developers about the good practices when developing your tests. This will save your time later when you need to maintain or change the code.

 

3.Not understanding test design patterns

The problem: This one is a bit more technical, but you are a technical person now so you will inevitably encounter page object and page factory design patterns. Make sure you understand them in order to use them correctly.

The solution: Wrapping your object in page objects makes your code both more readable and maintainable. You can start learning about it here.

 

4.Should you automate everything?

The problem: Many test engineers consider automation a replacement of the manual testing. Fully automating the testing can be dangerous and inefficient in the long run.

The solution: Grasp that automation is a tradeoff between time now and time in the future. Make sure you are automating tasks that are going to be happening more frequently. Here is a nice picture to help you grasp the concept:

is_it_worth_the_time_2x

Source: XKCD

Make sure you are not writing tests 8 hours in order to save 5 seconds.

 

Conclusion

In the end of the day automation is all about efficiency. Look for the quick wins that will give you the greatest value for the smallest effort, keep the best practices in mind and you will do great in the long run.

Happy Automating!

Leave a Reply

Your email address will not be published. Required fields are marked *