<linearGradient id="sl-pl-bubble-svg-grad01" linear-gradient(90deg, #ff8c59, #ffb37f 24%, #a3bf5f 49%, #7ca63a 75%, #527f32)
Loading ...

QA essentials

Your go-to quality assurance source

How To Improve Testing Framework Performance

Testing framework is used to allow maintainability of your tests. In E2E testing we usually use some of the well known patterns for automated execution of the tests. When we talk about performance of the tests we are concerned about infrastructure, flakiness, application loading times, etc. There are many things which influence the test performance. The optimization efforts usually target improvements of the infrastructure, improving the application under test, parallelization, etc. However, most people don’t think how the design of your framework affects the performance. Here are some of the ways to improve testing framework performance.

Data setup

The first thing we will discuss is test data setup. It is not uncommon to see that there are hard coded values for data in the tests. Another option is to set data through UI using the test script in some before block. The best way to setup data from performance perspective is to send data to the database through API and then work with that data in UI. The most common testing libraries and tools offer this functionality. Let’s see how this works in Cypress.

For demonstration purposes I have here one simple test which at first adds one item in the cart. Then the test checks if the item is added. I do it all through UI.

improve testing framework performance

Now, a better approach would be to use the API to send the item to the cart and then check the cart.

improve testing framework performance

Now let see what did we achieve with this. The first test finished in 4 seconds, while the second one finished in 3 seconds.

One second seems like a small improvement, but it was a fast and short test in the first place. For more complex tests the benefits are even higher.

User journey optimization

Another common issue in writing tests is clicking through UI as user would do to get to a certain page. In the above example I open first the home page and then after I add the item to the cart I click on cart button. TO improve our testing framework performance a better approach would be to go directly to cart page after sending the request with data. Let’s see that in action.

improve testing framework performance

And now after this change lets run another test and see what are the results in execution times. Remember the first test completed in 4 seconds as shown above.

test improvement results

The test completed in 1 second. If I compare that to the initial test, we’ve made 75% improvement with two simple changes in the test design.

Conclusion

Simple design changes can literally improve the testing framework performance by a lot. We haven’t created any parallelization, we haven’t done any infrastructure improvements, no optimization of the system under test. The only thing I did was a simple change of my thinking about the test. I showed before already how to improve the performance of the tests with reusable sessions which is also a great technique. The advice from these two articles are very helpful for optimizing the performance of your testing framework.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome content in your inbox, every month.

We don’t spam! We keep your data private and share it only with third parties that make this service possible. Read our privacy policy for more info.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.