Software Development

The Truth About AI and Test Automation

Software testing has gradually evolved in the past few decades. In the past, teams were accustomed to the waterfall methodology: Everything was sequential, from requirements to product deployment.

Only after the development phase was completed did the testers got their hands on the product. Historically, testers would find a number of bugs in this phase, and it would take a lot of redesign and rework to fix them. This resulted in a lot of wastage, from time to effort and cost, plus team morale.

But in the current state of testing, most companies are following Agile processes, such as XP, Scrum, Kanban, or some variation of these. The main goal is to find bugs fast, fix them quickly, and release software faster.

In order to achieve this goal, there is a huge need to complement the already existing manual testing process with automated testing. This is a vital component of Continuous Integration (CI), Continuous Delivery (CD), and DevOps, which most teams are now following to make their Software Development Life Cycle (SDLC) process more lean and effective.

Various tools and frameworks have evolved in the past decade to help with automated testing, but one approach worth talking about is the use of Artificial Intelligence (AI) in test automation.

Test Automation

De-Mystifying Artificial Intelligence

Let’s first take a step back and de-mystify AI. At its most basic level, AI is a technology that can comprehend, sense, and learn, and use computers to solve problems typically requiring human intelligence and understanding.

Another way of looking at it is, AI applies human skills and tendencies to inanimate objects or ideas. Much like automation, AI makes it possible for technology to complete real human tasks.

Contrary to popular opinion, AI is neither a distant reality nor a concept based on the plots of science fiction; instead, it has infiltrated the technology scene and is fueling the innovations that touch our daily lives. From chat bots posing as customer service representatives to search results and traffic predictions, on any given day, AI is all around us.

Here are some mind blowing statistics about AI adoption:

  • According to a recent study by Narrative Science, 61% of businesses implemented AI in some way in 2017. The adoption rate is only growing in 2018.
  • Another study from Juniper Research has found that global retailer spending on AI will reach $7.3 billion per annum by 2022, up from an estimated $2 billion in 2018.
  • A CMO article claims that by 2035, AI will help to improve labor productivity by 40% and enable people to make efficient use of their time.

Influence of AI in Test Automation

AI has already started influencing test automation in various ways, resulting in a considerable amount of time saved in authoring and executing tests, creating more stable tests, finding bugs fast, and releasing software much faster to meet customer demands. Here are some of the ways this is happening.

Faster and More Stable UI Tests

As part of the continuous testing process, software development teams have unit tests, service/API level tests, and user interface (UI) tests. The common problem with UI tests specifically is that they are slow and brittle and involve high maintenance. AI can avoid this with the use of Dynamic Locators.

This is a strategy by which the AI parses multiple attributes of each and every element the user interacts with in the application and creates a list of location strategies, in real time. So, even if an attribute of an element changes, the tests do not fail; instead the AI detects this problem and goes to the next best location strategy to successfully identify the element in the page.

In this way, the tests are more stable, and as a result, the authoring and execution of tests is really fast as well.

Test Automation

Reducing Maintenance and Eliminating Flaky Tests

One of the most common problems with test automation is maintenance.

For example, say we have 100 automated tests running on a daily basis to ensure the main functionalities of the application are still stable; What if the next day we come back to work and find that half of the tests have failed? We would need to spend considerable amounts of time to troubleshoot the failures and investigate what actually happened. This involves figuring out ways to fix the failures and implement the fixes. Then, we re-run the automated tests to ensure everything passes. Does this ring a bell?

AI can avoid issues like this due to its self-healing mechanism. It can start detecting problems in the tests before they even occur, thus proactively fixing tests instead of us reacting to them.

Based on the number of times the tests have run, the AI can figure out which tests are stable or flaky. As a result, it can give us data on what tests need to be modified to ensure test runs are stable.

Finally, based on large numbers of test runs, AI can optimize the wait times used in tests to wait for the pages to load and also can handle tests running on different resolutions. All of this adds up to a considerable decrease in the time spent on maintenance of tests and helps to solve one of the biggest bottlenecks of continuous testing.

Test Automation

Continuous Learning from Production Data

In this fast-paced environment where customer is king, it is important to observe and learn how customers use our product. This is true whether you have a web, mobile, or desktop application.

With autonomous testing, we now have a way for AI to start observing and learning how our customers are using the product. Based on this, it can start creating tests based on real user data.

It is smart enough to identify commonly used actions such as logging in/out of the application and cluster them into reusable components. Then it injects these newly created reusable components into our tests as well. Now, all of a sudden we already have actual tests written by the AI based on real data, along with reusable components that can be used within other tests as well.

Test Automation

This reminds me of a quote from the great Steve Jobs: “Start with the customer experience and work backwards.”

Removing Dependencies

Another challenge of test automation is writing tests for a system that may have dependencies on other modules that may or may not have been implemented yet. Usually during these times, we mock responses from a server or database. Now AI can help to do this for us.

Once we have authored some tests and have run them consistently for a period of time, the AI can start recording all the server responses. The next time we run the tests, instead of talking to a server or database, the test will access the stored responses (which was facilitated with the help of AI) and will continue to run without any obstacles.

As a result, the tests run much faster, since the delay in waiting for a response is eliminated and the need to rely on a physical database or server has completely been erased.

Test Automation

Ease of Authoring and Executing Tests

Some of the biggest obstacles keeping companies from moving forward with automation is the amount of time and effort it takes to author and execute tests with the chosen tool or framework and the availability of skilled resources to do this task.

Even when companies decide to move forward with automated testing, teams have to spend considerable amounts of time authoring and executing tests due to complexity of the application, tools available, and the programming language used.

Now, there are AI-based tools that help to mitigate these problems. Tests that used to take one week to author and execute can now be done in a matter of hours using AI. This is possible with the use of Dynamic Locators and the ability to easily create reusable components, do data-driven testing, author and execute tests quickly, and integrate CI/CD systems easily with public and private grids. As a result, we are able to have reliable tests, more test coverage, less maintenance, and faster release cycles.

Also, this has opened up a new era in test automation where nontechnical people can get involved in test automation as well. This helps to increase collaboration within teams and encourages everyone to own the test automation effort. AI is now bringing a whole-team approach to test automation.

Test Automation

Releasing at the Speed of Development

With AI powering the transition to autonomous testing, reducing the maintenance to a minimum, and creating more reliable tests, the ability for teams to release faster is better than ever.

With AI and autonomous testing, quality assurance (QA) can focus on exploratory tests, while a big portion of the tests are continuously created and updated automatically. Now, your release frequency is only limited by how quickly your developers can code. It is also easier for QA to maximize user coverage by connecting authoring of tests with production apps mapping to real user flows.

Now, we have the ability to take a risk-based approach and base our decisions on real data. Most of all, we are ahead of the game by proactively fixing issues instead of reacting to them, because of the self-healing mechanism of the AI.

Also, we are now able to create more user scenarios in short period of time. This means you can find bugs fast and release faster. The future of testing has only become brighter with AI.

If you have experienced or heard of other ways to implement AI in test automation, please share your thoughts below in the comments section.

Published on Java Code Geeks with permission by Raj Subramanian, partner at our JCG program. See the original article here: The Truth About AI and Test Automation

Opinions expressed by Java Code Geeks contributors are their own.

Raj Subramanian

Raj Subramanian is a former developer who moved to testing to focus on his passion. Raj currently works as a Developer Evangelist for Testim.io, that provides stable self-healing AI based test automation to enterprises such as Netapp, Swisscom,Wix and Autodesk. He also provides mobile training and consulting for different clients. He actively contributes to the testing community by speaking at conferences, writing articles, blogging, making videos on his youtube channel and being directly involved in various testing-related activities. He currently resides in Chicago and can be reached at raj@testim.io and on twitter at @epsilon11. He actively blogs on www.testim.io and his website www.rajsubra.com . His videos on testing, leadership and productivity can be found here.
Subscribe
Notify of
guest

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

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button