What is Artificial Intelligence in Software Testing?
One of the most recent buzzwords in the software development industry is artificial intelligence. But what does it really mean? How does AI in the context of software test automation differ from its broader definition?
What do we mean when we talk about AI and its sister term, machine learning? I thought I would clear up our usage so it’s clear how we are using AI and machine learning to advance the state-of-the-art in software testing.
How to implement AI in test automation (it's not just buzz)
Artificial intelligence is one of the most overloaded buzzwords in the marketplace. “AI” conjures up images of things like all-powerful super-computers, hell bent on human destruction; voice-control assistance in the way of Alexa or Siri; computer chess opponents; or self-driving cars.
Wikipedia defines AI research as "…the study of "intelligent agents": any device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals.” But that's a little too abstract. I like to think of AI as the ability of a computer program or machine to think (reason for itself) and learn (collect data and modify future behavior in a beneficial way). It’s in this definition that we start to see something more meaningful in the context of what AI means for software development tools and technology.
It’s also important to realize that the scope of what is considered "AI" changes over time. At one time, for example, optical character recognition (OCR) was considered state-of-the-art in AI. Or the question-and-answer responses from Siri and Alexa, which at one time were considered state-of-the-art, are now largely taken for granted and not always considered AI. The same thing will happen with software testing tools -- innovations in automation today will become expected as new capabilities evolve. But for now, let's consider AI in software test automation in 2018.
AI in Software Test Automation in 2019
The use of AI in software development is still in its infancy, and the level of autonomy is much lower than seen in more evolved areas such as self-driving systems or voice-assisted control, although it is still driving forward in the direction of autonomous testing. The application of AI in software testing tools is focused on making the software development lifecycle easier. Through the application of reasoning, problem solving, and, in some cases, machine learning, AI can be used to help automate and reduce the amount of mundane and tedious tasks in development and testing.
"Don’t test automation tools do this already?" you might ask.
And the answer is of course, "Yes! They do!" ...but they have limitations.
Where AI shines in software development is when it is applied to remove those limitations, to enable software test automation tools to provide even more value to developers and testers. The value of AI comes from reducing the direct involvement of the developer or tester in the most mundane tasks. (Human intelligence is still very much needed in applying business logic, etc.)
For example, consider that most (if not all) test automation tools run tests for you and deliver results. Most don’t know which tests to run, so they run all of them or some predetermined set. So what if an AI-enabled bot can review the current state of test status, recent code changes, code coverage, and other metrics, decide which tests to run, and then run them? Bringing in decision-making that’s based on changing data is an example of applying AI (And Parasoft does this, by the way). The software is effectively able to replace the developer/tester in the decision-making process. The benefit of applying this to a CI/CD pipeline is clear.
AI and Machine Learning
So, what about machine learning? Machine learning can augment the AI by applying algorithms that allow the tool to improve automatically by collecting the copious amounts of data produced by testing.
Machine learning research is a subset of overall AI research, with a focus on decision-making based on previously-observed data. This is an important aspect of AI overall, as intelligence requires modifying decision-making as learning improves. In software testing tools, though, machine learning isn’t always necessary -- sometimes an AI-enabled tool is best manually fine-tuned to suit the organization using the tool, and then the same logic and reasoning can be applied every time, regardless of the outcome.
In other cases, data collection is key to the decision-making process, and machine learning can be extremely valuable, requiring some data initially and then improving or adapting as more data is collected. For example, code coverage, static analysis results, test results, or other software metrics, over time, can inform the AI about the state of the software project.
Real Examples of AI and Machine Learning in Software Testing
This is an important area of research and development at Parasoft. Excitingly, our current offerings are just the beginning, and our ongoing research in AI and ML continues to bring new ways to integrate these technologies into our products. Here are a few ways we have already brought them in.
Using artificial intelligence to automate unit test generation and parameterization
This first example is in Parasoft Jtest, our software testing solution for Java developers that includes static analysis, unit testing, coverage and traceability, etc. Applying AI here, we've released automatic test case generation, which helps developers fill in the gaps when starting from a sparse JUnit harness.
Parasoft Jtest’s IDE plug-in adds useful automation to the unit testing practice with easy one-click actions for creating, scaling, and maintaining unit tests. By using AI-enabled Jtest, users can achieve higher code coverage while cutting in half the time and effort required to build a comprehensive and meaningful suite of Junit test cases.
One way it does this is by making it easier to create stubs and mocks for isolating the code under test. The underlying AI enables Jtest to observes the unit under test to determine its dependencies on other classes, and when instances of these dependencies are created, it suggests mocking them to the user to create more isolated tests. Automatically creating the necessary mocks and stubs reduces the effort on one of the most time-consuming parts of test creation.
Parasoft Jtest also automatically detects code that isn’t covered by existing test suites and traverses the control path of the source code to figure out which parameters need to be passed into a method under test, and how subs/mocks need to be initialized to reach that code. By enabling this AI, Jtest can automatically generate new unit tests, applying modified parameters to increase the overall code coverage of the entire project.
Using AI and machine learning to automate API test generation and maintenance
Another good example, adding machine learning into the mix, is Parasoft SOAtest's Smart API Test Generator, that goes beyond record-and-playback testing, leveraging AI and machine learning to convert manual UI tests into complete, automated API test scenarios.
The Smart API Test Generator uses reasoning to understand the patterns and relationships in the different API calls made while exercising the UI. From that analysis, a series of API calls is constructed that represents the underlying interface calls made during the UI flow. It then applies machine learning by observing what it can about the different API resources and storing them as a template in a proprietary data structure. This internal structure is updated by examining other test cases in the user's library to learn different types of behavior when exercising the APIs, for example, an assertion, or adding a particular header at the right spot.
The goal of AI here is to create more advanced tests (not just repeating what the user was doing, as you get with simple record-and-playback testing). The tool recognizes patterns inside the traffic, creates a comprehensive data model of observed parameters, generates automated API tests, and enables applying learned patterns to other API tests to enhance them and help users create more advanced automated test scenarios. The resulting automated API tests are more complete reusable, scalable, and resilient to change.
The Future of Artificial Intelligence and Machine Learning
So what comes next? We are in active R&D in this space, continuing to pursue further applications of artificial intelligence and machine learning to augment our software testing tool suite. There are many routes of research, but the end goal is clear: to help teams develop and test their code more efficiently and effectively, to create higher quality software at speed.
Parasoft's VP of Development, Igor is responsible for technical strategy, architecture, and development of Parasoft products. Igor brings over 20 years of experience in leading engineering teams, with a specialization in establishing and promoting the best agile practices in software development environments.