DEV Community

Cover image for Challenges Of Automation Testing
Oswin Losper
Oswin Losper

Posted on

Challenges Of Automation Testing

I think it's safe to say that in todays world, client and stakeholders expect software application they use everyday to provide them with rich experiences. The days of simple applications with a few form fields and store basic data are gone. We live in a world where we have real-time applications with nice designs and multiple services on the cloud.

Because of this applications can become very complex with a lot of moving parts. With this, testing has also become much more complex, with multiple pieces of functionality working differently and stores information in different locations.

Developers and tester needs to make sure that all of the pieces of the puzzle of their applications works well together. Usually these complicated applications are being tested manually, but let's be honest we are humans after all and we do get tired and this is prone to mistakes. One way to get over this mistake is to implement automated end-to-end testing. Along side other automated tests like unit and API testing, end-to-end tests are essential part of the software development lifecycle.

What is end-to-end testing

End-to-end testing, or E2E testing, is to make sure the  whole work flow on an entire application works from start to finish. Unlike other kinds of testing, end-to-end testing goes through the whole functionality, not just a certain part. Applications that interact with different services or require complex actions, this type of testing simulates real world scenarios and validates what your customers see.

Benefits of end-to-end testing and Automation

End-to-end tests provide a few benefits over other forms of testing. These tests will simulate a real word scenario that your customers will also experience under normal circumstances. Other tests do not simulate a real world scenario but only a section of the functionality that a user experiences. This kind of coverage helps to ensure that third-party services that aren't in your control work as intended. And thanks to the rise of low-code or code-less testing tools, the barrier to entry for creating end-to-end testing is much lower.

Some teams perform these complex tests manually, going through each step to cover their acceptance criteria. As mentioned earlier, this process take time and this can lead to tiredness and mistakes set to creep in and can even rush to tick all the boxes on the acceptance criteria and just forget to do their work, however more and more businesses are now leveraging the power of automation testing to free them from doing the same stuff over and over again.

Because automated tests does simulate real world scenarios quicker then a human would perform these steps, the entire team can get quicker feedback if something went wrong in there application.

This is just a few benefits of end-to-end automation. For more on this, few my blog post on benefits of automation testing

Challenges of end-to-end testing

As saying the goes in the perfect world, I think we all want that, but we do live in the real world. With that everything that sounds good also does have its flaws, and its no different for automation testing either, as much as we want it to solve all our testing problems, it doesn’t come with its own sets of challenges. It's important that, when you do start your automation journey that you understand the challenges and have plans in place to fix them.

I have worked with companies that told me, they want to automate everything without thinking of the challenges that lays ahead and if these challenges are not planned for, your automation dream wil soon turn into a nightmare. 
Below are challenges most testers face with end-to-end testing and also a few tips on how to overcome each to make you turn into an E2E testing hero.

Challenge #1: Flaky Tests

End-to-end testing has an earned reputation for unstable, flaky tests that fail irregularly. It’s very frustrating, if you run your test suite and everything passes, only to see a test fail for no reason the next day but they passed yesterday and there were no code changes.

End-to-end testing does consist of a lot of moving parts and needs to validate different components through a test run, it is difficult to isolate whats causing the issue. This inconsistency leads to a lot of lost time trying to figure out the root cause of the flakiness since it’s nearly impossible to replicate the failing scenario. And worse of all, flaky tests leads to teams accepting them, ignoring potential issues and decreasing the value of automation tests.

The main challenge of tackling an unstable test suite is to find a solution. You can take a few steps to minimise inconsistent tests. Keep in mind there is no one-size-fits all quick fix for this.

Keep track of test failures: On most automated test suites with flaky tests, you’ll often see the same test cases fail. The tests will give you ideas or clues that can help you iron out the instabilities in the application or the test suite.

Make the most of your testing tools: Most end-to-end tools has build in features that can re-run failing tests. For instance, if you run your test against a live API, you will most probably get time-outs, and you don't want these to be marked as failed. For example, TestCafe has a build in feature called quarantine mode, if a test fails it will run the test again and if it passes on the second attempt it will mark it pass or unstable.

Don’t ignore flaky tests: Ignoring a flaky test will not make the problem go away, it will lead to acceptance of flaky tests and this can lead to actual problems being ignored as well. We all would like to have more time in the day, but set time aside for investigate flaky tests before the problem gets worse.

Challenge #2: Slow Tests

Besides flaky tests, another top complaint is that end-to-end tests are slow and will slow down building times. As mentioned before end-to-end test goes through the entire stack and test every component, both internal and third party. Its just plain unfair to compare end-to-end testing with the speedy unit tests that only test a partial section of your application.
Even with saying that it doesn't make the end-to-end tests go faster, because a slow test suite can drastically slow down the effectiveness of software development and testing teams.

For instance, a lot teams now rely on successful test runs in the continuous integration system before merging code or deploying new features. Having to wait for these build can grind your work to a stand still.

Speeding up your tests can rely on different factors, your architecture of your application, any dependencies or third party services and network connectivity to mention a few. Your strategy will vary according to the application. The following are some steps you can follow to speed up your tests.

Mocking and stubbing functionality: Most applications these days connect to multiple external services or have to perform complex calculations. You can avoid the overhead of these time consuming functions by using mocks to simulate the behaviour of the functionality.

Set up the correct data as needed: Your tests can spend too much time setting up the applications initial state and cleaning things up after a test run. Take time to review the best way to ensure your test has what it needs - nothing more and nothing less.

Build your test to run concurrently: Most end-to-end testing tools like TestCafe, allow you your tests in parallel with one another or use multiple browsers. Your test scenario have to run independently from one another.

Challenge #3: Long-Term Maintenance

One very important aspect of end-to-end testing, is that businesses under estimate the amount of maintenance goes into end-to-end testing. Lot of businesses think, that once you are done with an application feature, the end-to-end testing doesn’t need maintenance, very easy mistake to make but its wrong.

As you add more testcases to your test suite, over time your team may will begin to struggle to keep the test under control. It will become very difficult to add new test cases without effecting existing ones.

A mistake many testing teams make is to automate everything and not thinking about the management of the tests down the road. The focus to automate everything, this mindset leads them down a road where the tests become more detrimental than helpful. To avoid falling into this trap, here a few thing to consider before you begin your end-to-end tests.

Define your test suite structure from the start: At the start of your end-to-end journey take the time to plan test suite structure, for example: you directory structure, helper files, page object models and so on. The time you spend in setting these up will pay of in the long run.

Reorganise as soon as the opportunity presents itself: When you feel some of your files or code could be organised in a better way, do it as soon as you can to keep your test suite tidy at all times. It's quicker to refactor and rearrange your tests while you're working on them.

Know your tools: Knowing what your testing tools can and can't do, this will help shape your decisions on how to write your tests in the best way possible for long-term use.

Challenge #4: Demonstrating Value

Like mentioned above, companies under estimate the amount of time and effort needed to implement end-to-end automation testing. Yes, we do have advanced automated testing tools these days. Each project has its own set of needs, so it's not as simple as deciding to build an automated test suite. Teams need to plan their strategies, choose how to allocate resources and find time to start.

Sadly, many organisations are unaware of how automated testing can help the long term health of their projects. These companies look primarily for a return on their investment. 
Since it's difficult to immediately see value of end-to-end testing at the start of a project, it can lead to the organisation abandoning its efforts too quickly without anything to show for it. Also the primary focus is making management loose focus on the long term of their project that they don’t take the time to understand what end-to-end testing is. This leads to management question end-to-end testing value.

With some early preparation work you can begin to show the benefits of what you creating. If you're in a situation where you feel like you need to produce results and demonstrate the value of end-to-end testing, you can take a few measures to show that your work is helping everyone involved in the project:

Make your results visible to the teams: Show the entire team that your end-to-end test suite is working by displaying test run results using tools like Slack, emails, dashboards or any other place the team can see them quickly and effortlessly.

Make your results visible to the teams: Almost all testing tools can generate a well organised report that show how your tests performs.

Keep track of how your tests improve your project: Come up with a list of valuable metrics you can measure for the project, like defects found before a release, development velocity and so on. Once you have a list of metrics, take a baseline measurement and see how they improve over time as your end-to-end test suite expands.

Conclusion

End-to-end testing is a vital part of an application. It complements other forms of testing, such as unit testing or functional testing, by providing additional coverage and exercising the system as a whole. An end-to-end test can uncover issues that other isolated tests might not expose and works best if you have an application with different services interacting with each other.

However, the total amount of coverage provided by end-to-end tests also means increased complexity in managing them. The tests can be unstable and slow, requiring extra attention to keep them running smoothly. It's also challenging to demonstrate immediate value since they take longer to put into action. By following the tips listed in this article, you'll reduce these issues and provide a boost in quality across the entire project. 

Automating end-to-end tests can be tricky and hard to show your organisation that they're working. You'll need more time to plan, implement and execute. Once running, you'll also have to ensure they're working for your needs instead of slowing everyone down. But when done right, these tests will save your team countless hours of manual testing and make your application and team better for it.

Top comments (0)