Unit Testing is a tedious, often monotonous, but crucial activitiy in every software development project. In this article, I show you how the intrusion of Artificial Intelligence (AI) techniques into current unit testing practices will change the way we are approaching unit testing – to the better. The main benefit will be the automation of redundant and monotonous activities that currently have to be carried out manually, because they require a certain level of human intelligence. Additionally, optimization techniques will become more prominent withint the testing process. As a result, the role of a unit tester will shift fundamentally to be suitable as a human twin that guides the artificial intelligence through the unit testing process. So let’s look at these aspects in a bit more detail.
Reducing duplicate work
Scructured ways to define specifications can already be used to automatically derive unit testing (this is usually refered to as Behavior Driven Development). However, such definitions usually require a lot of effort (often the same effort than writing test code in the first place). Artificial Intelligence can reduce this effort by assisting in the definition of such specifications. Already defined information can be reused to recommend information that has to be entered next (this approach has already shown great results in current low-code platforms such as Mendix “AI-Assisted Development”). For software testing, this means that test cases, or even equivalence class partitionings, can be reused for similar methods to be tested. For equivalence classes, the representatives to be used for creating test cases can also be chosen automatically based on past decisions. However, even test cases are generated automatically, they have to be run over and over again, to analyze the test results after every run and derive actions. To keep this manageable, a unit tester has to ensure to keep the set of test cases as small as possible, but still provide sufficient coverage of relevant code paths. All these steps mentioned above can be automated by (i) automaticaly chosing regression tests (e.g. using genetic search algorithms), (ii) automatically running them (not really AI, to be fair), and (iii) analyzing test results over time to derive actions based on outliers in these results (e.g. using unsupervised machine learning techniques).
Using modern AI techniques, optimization becomes both fast and easy. So-called meta-heuristic search algorithms can calculate the optimum combination of different aspects, trading off multiple conflicting goals. To improve calculation speed, these algorithms use so-called heuristics to only consider a sub-part of the overall search space of possible combinations. Applied to unit testing, this means that in the future, (i) the number of tests in a test suite will be optimized, trading off conflicting metrics such as execution time and code coverage (ii) new ways to evaluate test cases will be developed, based on additional information that can be taken into account (e.g. previously identified defects, or similarities to already tested code paths) (iii) mutation testing and metamorphic testing will become more relevant due to automation of finding optimum mutants and metamorphic relations.
When you visit any web site, it may store or retrieve information on your browser, mostly in the form of cookies. Control your personal Cookie Services here.