Searching for test data with feature diversity

by   Robert Feldt, et al.
Chalmers University of Technology

There is an implicit assumption in software testing that more diverse and varied test data is needed for effective testing and to achieve different types and levels of coverage. Generic approaches based on information theory to measure and thus, implicitly, to create diverse data have also been proposed. However, if the tester is able to identify features of the test data that are important for the particular domain or context in which the testing is being performed, the use of generic diversity measures such as this may not be sufficient nor efficient for creating test inputs that show diversity in terms of these features. Here we investigate different approaches to find data that are diverse according to a specific set of features, such as length, depth of recursion etc. Even though these features will be less general than measures based on information theory, their use may provide a tester with more direct control over the type of diversity that is present in the test data. Our experiments are carried out in the context of a general test data generation framework that can generate both numerical and highly structured data. We compare random sampling for feature-diversity to different approaches based on search and find a hill climbing search to be efficient. The experiments highlight many trade-offs that needs to be taken into account when searching for diversity. We argue that recurrent test data generation motivates building statistical models that can then help to more quickly achieve feature diversity.



page 1

page 2

page 3

page 4


A Factorial Experiment on Scalability of Search Based Software Testing

Software testing is an expensive process, which is vital in the industry...

Towards Constraint Logic Programming over Strings for Test Data Generation

In order to properly test software, test data of a certain quality is ne...

Using mutation testing to measure behavioural test diversity

Diversity has been proposed as a key criterion to improve testing effect...

Enhancing Path-Oriented Test Data Generation Using Adaptive Random Testing Techniques

In this paper, we have developed an approach to generate test data for p...

Model Similarity Mitigates Test Set Overuse

Excessive reuse of test data has become commonplace in today's machine l...

Practical Model-driven Data Generation for System Testing

The ability to generate test data is often a necessary prerequisite for ...

Agree to Disagree: Diversity through Disagreement for Better Transferability

Gradient-based learning algorithms have an implicit simplicity bias whic...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Most testing practitioners know that a key to high-quality testing is to use diverse test data. However, it is only recently that there has been research to formalise different notions of diversity and propose concrete metrics to help realise it [1, 2, 3, 4]. The diversity that is sought is often of a general shape and form, i.e. rather than target some specific attribute or feature of the test data we seek diversity in general. Even though this is appropriate when little is known about the test data that is needed, it makes it harder for testers to judge if diversity has really been achieved and of which type. Moreover, if the tester has some prior information or preference as to which type of test data to explore it is not clear, in the general diversity context, how to incorporate this during testing.

Here we target a specific form of test diversity (TD) that we call the Feature-Specific TD problem: how to sample as diverse and complete set of test inputs as possible in a specific area of the feature space. As a concrete example, for software-under-test that takes strings as inputs, a tester might prefer test inputs that are in a particular size range (feature 1) and for which the count of numeric characters is within a given range (feature 2). This problem is in contrast to the General TD problem where we seek diversity in general without requiring diversity within in a particular set of features.

There is existing work on how to search for test data with one specific set of feature values [5], as well as techniques that address the General TD problem, but there is a lack of work on the Feature-Specific TD problem. In this paper we propose a variety of methods to generate test data with specific types of feature diversity, and then explore their strengths and weaknesses in order to understand the trade-offs between them.

Our contributions are:

  • Identification of multiple basic methods to search for feature-specific test diversity,

  • Evaluation of the basic approaches on a two-dimensional feature space for a test data generation problem,

  • Proposal of hybrid search methods based on the results of the evaluation.

In Section 2 we provide further background and summarise related work. In Section 3 we propose the search-based methods to seek feature-specific diversity, and describe and discuss their evaluation in Section 4. We then summarise our conclusions in Section 5.

2 Background and Related Work

Test data generation techniques often apply a strategy that has an implicit objective of ensuring some form of diversity in the set of test inputs that are created. Testing techniques that partition the input domain – for example, based on the structural coverage of the software-under-test – select a representative test input from each partition and so implicitly achieve diversity in the context of the criterion used for partitioning. Even uniform random testing implicitly achieves some form of diversity simply because every input in the input domain has the same, non-zero probability of being selected for the test set.

In contrast, there exist test data generation techniques that have an explicit objective of diversity within the input domain. One class of such techniques use a distance metric between two test inputs, such as the Euclidean distance between numeric inputs, and interpret this metric as a measure of diversity to guide the selection of test inputs.

Antirandom Testing chooses a new test input such that is maximises the total distance between the new datum and all the existing inputs already in the test set [6]. Adaptive Random Testing first creates a pool of candidate inputs by random selection, and then adds to the test set the input in the candidate pool for which the minimum distance from all existing members of the test set is the largest [7]. Both these techniques therefore create a set of test inputs element-by-element by selecting the next test element to be as dissimilar as possible from existing elements.

Bueno et al. consider instead the set of test inputs as a whole, and define a diversity metric on the set as sum of the distances from each input to it nearest neighbour [8]. Metaheuristic search is then applied to the set of test inputs with the objective of maximising the diversity metric. Hemmati et al. apply both the element-wise approach of Adaptive Random Testing and a whole-set approach similar to that of Bueno et al. to the selection of diverse cases derived using model-based testing [9].

Diversity metrics based on Euclidean distance are limited in terms of the types of inputs to which they can be applied. Feldt et al. demonstrate that normalised compression distance, a distance metric based on information theory, is not limited in the data types to which it may be applied, and enables the selection test inputs in a manner similar to how a human would based on ’cognitive’ diversity [1]. Normalised compression distance is a pair-wise metric, but a recent advance in information theory extends this notion to a set as a whole. Feldt et al. use this set-wise metric to introduce test set diameter, a diversity metric that is applied to the entire test set, and demonstrate how this metric can be used to create diverse test sets [3].

Panichella et al. demonstrate an alternative mechanism for promoting diversity in the context of selecting test cases for regression testing. Instead of a search objective based on diversity, the authors propose a multi-objective genetic algorithm in which the genetic operators – in this case the initialisation of the population and the generation of new individuals – are designed to ‘inject’ diversity at the genome level


In the above approaches, the notion of diversity is generic in the sense that it is agnostic as to the ‘meaning’ of the test inputs. Metrics such as Euclidean distance or normalised compression distance simply treat the inputs as numeric vectors or strings of symbols, respectively, rather than aircraft velocities, time-series of temperature measurements, or customer addresses etc. The advantage of generic diversity metric and generic algorithm operators is that they can be applied easily to any domain, but the risk is that they may overlook domain-specific notions of diversity that might be important in deriving effective test inputs.

In this paper, we investigate instead how to measure and apply diversity that takes into account the domain-specific meaning of the test inputs. We take inspiration from a recent class of evolutionary algorithms known as illumination algorithms or quality diversity algorithms

[11]. These algorithms differ from traditional evolutionary algorithms in that they forego the use of objective fitness as the primary pressure that drives the selection of new individuals, and instead select new individuals based on the domain-specific ‘novelty’ of the phenotype. The premise is that the search for novelty maintains diversity and avoids premature convergence to local optimum. Or considered another way, the pressure for ever-increasing objective fitness can prevent the algorithm from finding the sequence of ‘stepping stones’ that leads to the glabal optimum. These algorithms have been shown find near-globally optimum solutions as a by-product of the search for novelty.

For example, Lehman and Stanley’s novelty search algorithm evaluates new individuals in terms of a novelty metric, and this metric is unrelated to the objective metric [12]. To calculate the novelty metric, domain-specific features of the phenotype are measured to obtain a feature vector, and then measures the distance of the individual from its nearest neighbouring individuals in this feature space: the larger this distance, the more novel the individual is considered to be.

The Multi-dimensional Archive of Phenotypic Elites (MAP-Elites) algorithm of Mouret and Clune uses the feature-space to maintain diversity in a different manner: at each point in the feature space (which is discretised for this purpose), an archive is maintained of the best individual having the features, where best is measured in terms of objective fitness [13]. The set of these elite individuals – one at each point in the feature space – is the population on which the evolutionary algorithm acts.

We note that Marculescu et al. apply both novelty search and MAP-Elites to generate candidate test inputs as part of an interactive search-based software testing system, and found that, compared to a traditional objective-based evolutionary algorithm, the illumination algorithms found more diverse test cases [14].

It is this general strategy of illumination algorithms – that of searching for diversity in a domain-specific feature space – that informs the work in this paper. In addition, the specific strategies employed by Novelty Search and MAP-Elites are the basis for some the approaches we investigate.

3 Focused Search for Feature Diversity

The research described in this paper is motivated by the premise that test data chosen for feature-specific test diversity will be more effective than test data chosen according to more generic measures of diversity (such as those discussed in section 2 above). The objective of the research is then to explore a number of search-based methods for choosing test inputs with high feature-specific diversity.

In this section, we describe:

  • a concrete testing scenario (described first since a feature space is scenario-specific);

  • a feature space for the testing scenario;

  • a base mechanism for generating test inputs for this scenario;

  • a set of search-based methods that can be applied to base mechanism to promote feature-specific diversity (the empirical work in section 4 will compare the effectiveness and efficiency of these methods).

3.1 Testing Scenario

The input domain consists of strings that are arithmetic expressions formed from the operators +, -, *, and /; integers; and parentheses. An example of a valid input is the string: "42+(-7*910)". We choose this domain since it is realistically complex: inputs are not simply numeric, but instead a string of characters that must satisfy constraints on its structure, and there is no bound on the length of the expression string.

We do not explicitly define the software-under-test in this scenario since the search-based methods we apply act on the inputs themselves rather than on the coverage or other information from executing the software. But we have in mind software that parses the arithmetic expression and calculates the result.

3.2 Feature Space

By ‘feature space’, we mean the specification of one or more named dimensions on which test inputs can vary on a defined scale. Typically this scale is numerical and each feature has associated with it a specific function that maps input onto the scale, but the scale can also be ordinal or categorical

For the purposes of the empirical work, we consider a two-dimensional feature space formed by:

Feature 1: Length

– the number of characters in the string

Feature 2: NumDigits

– the number of characters that are digits (‘0’ to ‘9’ in the ASCII range)

We envision that the tester wishes to generate a large number of test inputs that differ in both total length as well as in the number of digits.

Feature spaces can be very large, and may be infinite. This is indeed the case in this scenario: there is no bound on the length of either the expression string, nor the number the number of digits in the string. Therefore a tester needs to define a preferred area of the feature space where testing should be focused. For example, she may specify a range of values for each feature that together define a hypercube within the feature space.

3.3 Base Generation Mechanism

In order to generate valid test inputs, we use Feldt and Poulding’s GödelTest framework for generating structured data [5]. In this framework, a programmatic generator is used to define the structure of valid inputs – here, the structure of valid arithmetic expressions 111The generator we use for arithmetic expressions is the same as that included as an example in the README file for the DataGenerators package at: The DataGenerators package is Feldt and Poulding’s implementation of GödelTest in the language Julia. – and a choice model is used to control which of all the possible valid arithmetic expressions is emitted by the generator.

For this work, we use stochastic choice models that, in effect, define a probability distribution over the space of all valid arithmetic expressions. With such choice models, GödelTest becomes a mechanism for generating random arithmetic expressions according to the distribution defined by the choice model.

Choice models in GödelTest have parameters that can be used to change the probability distribution, and the search-based methods for diversity described below operate by manipulating these parameters.

The empirical work considers two stochastic choice models:


The default ‘sampler’ choice model provided by GödelTest. When used with the arithmetic expression generator, this choice model has 8 parameters all in the range .


An extension of the default choice model that enables more refined probability distribution. Specifically, the probabilistic choice of whether an operand in the expression is a number, or is itself a parenthesised subexpression, becomes conditional on the depth to which the current subexpression is nested. This choice model has 16 parameters, again all in the range .

3.4 Search-Based Methods

Our goal is to cover as large a portion as possible of the preferred area in the feature space. The fundamental approach we take is based on the novelty search algorithm described in section 2 above. The density (or simpler, even the count) of test inputs in a specific cell of the preferred area of the feature space as metric is used to guide the search to areas with lower density so that novel inputs can be found that will improve diversity of the test set as a whole. In addition, we consider several types of random search as baselines and investigate a more expressive stochastic model to govern the sampling of test inputs.

For random sampling, one can either set the GödelTest choice model parameters (which define a probability distribution over the valid inputs) to random values (i.e. to define a distribution at random) once at the start of the generation process, or continuously during the process. We call the former method rand-once and designate the latter rand-freqN with N denoting the frequency with which we resample the parameters. From previous research, it is known that some stochastic choice models can be quite brittle and lead to large numbers of ‘infeasible’ inputs – inputs that are extremely large or infinite and exceed the finite memory available to represent them – being generated. For this reason we also include a rand-mfreqN method denoting up to a maximum of N inputs sampled between resampling events. The maximum means that as soon as an infeasible input is generated, we directly resample random values for the choice model parameters.

For random sampling it is well-known that so called Latin Hypercube Sampling (LHS) can generate a better ‘spread’ of samples over a space [15]. When using LHS one first divides the value range for each dimension being sampled into equal-sized bins and then samples within each bin. This ensures that each dimension is sampled over the full range of its values. We select 10 and 30 bins respectively and designate the corresponding methods rand-mfreq5-LHS10 and rand-mfreq10-LHS30.

We also include Nested Monte-Carlo Search (NMCS) [16], a form of Monte-Carlo Tree Search that has been previously applied successfully to guide the generation of test inputs by GödelTest [17]. NMCS operates during the generation process itself rather than on the choice model parameters. Each time a decision needs to be made – such as whether an operand in the arithmetic expression is a number or a subexpression, or the number of digits in a number operand – NMCS performs an internal ‘simulation’ by taking each possible choice for that decision in turn, and for each, then completing the generation process as normal (i.e. using choice determined by the choice model). Whichever simulation results in the best outcome, the corresponding choice is made for that decision.

The variant of NMCS used by GödelTest considers a fixed sample of possible choices, rather than all possible choices, since there may be infinite number of such choices for a decision. We consider two variants in the evaluation: one that uses a sample of 2 choices at each decision, and the other uses a sample of 4 choices.

NMCS generates many ‘intermediate’ candidate test inputs as outcomes from its internal simulations, and there are several options for utilising these intermediates. We argue that it makes sense to not throw away these intermediates but rather use them to update the density used in fitness calculations. We include both an approach that updates the density directly and thus changes the fitness calculation for all subsequent samples, and a batch approach that fixes density during one exploration by the NMCS algorithm and then uses all intermediate test inputs to update the density in one go before the next generation is started.

Thus, we use four NMCS methods in the empirical evalution: nmcs-2-direct, nmcs-4-direct, nmcs-2-batch, and nmcs-4-batch.

Finally, we include a hill climbing method that is applied to parameters of the choice model. Since this is not a population-based method it is easier to control in detail how it compares the diversity of the inputs generated by new candidate parameters to the current model parameters. A new candidate is formed by making small changes to the current model parameters using a Gaussian distribution with a small standard deviation. We adapt the sampling and comparison step used in a traditional hill climber to try to minimize the number of sampled test inputs. After sampling a minimum number of inputs (4) we sample up to a maximum number (20) while discarding the new point if it generates more than 33% infeasible inputs, or 50% feasible inputs that are outside the preferred area of the feature space. It uses a Mann-Whitney U test to compare the densities in feature space of the test inputs sampled by the current parameters and the new parameters, and goes to the latter if the

-value of the test is below 20%. The settings (the number of samples, -value threshold, etc.) were chosen in an ad hoc manner, but the method seemed robust to changes in them during initial testing so we did not tune them further. This method is denoted hillclimb-4-20.

4 Empirical Evaluation

We applied all 10 methods defined above to search for diverse test inputs in the two-dimensional feature space defined by the string length and number of digits of the input. Each method was executed 25 times222Except for one long-running method, as detailed later. to account for (stochastic) variation in their performance. Below we discuss the results from two different perspectives: the coverage of the preferred area of the feature space, and the efficiency of the methods, i.e. their coverage compared to the search time they needed.

4.1 Feature space coverage

Once a tester has defined a particular preferred area of a feature space where she is interested in focusing attention our main concern is to create a set of test inputs that cover this area to the largest extent possible. Although there often exists many constraints between features, a tester may rarely be aware of them or have the time to define them in detail. We will thus assume that the focus area has the shape of a hypercube in the feature space, i.e. its limits are defined with one or more ranges of preferred values per feature. In this context it is natural to consider coverage in terms of how many of the unique combinations of feature values that has been covered during a search.

For example, in the two-dimensional feature space used here we have used the preferred area of lengths between 3 333We did not start at length 1 since the grammar of this particular generator is specified such that the shortest string possible is the one with two single-digit numbers with a single, binary, numeric operator between them, for a minimum string length of 3. and 50 and number of digits between 2 and 25 (both ranges inclusive). There is clearly a constraint between the features here, the number of digits has to be smaller than equal to the length of the string, but for other feature spaces and preferred areas the effect of dependencies and constraints might be harder to identify. We thus will use the theoretical maximum size of the preference hypercube We call this Feature Space Hypercube Coverage (FSHC), and denoted simply coverage in the following.

By definition this means that very rarely can a search method even in theory reach 100% FSHC for a specific preference hypercube; FSHC values should be compared only in relation to each other and not on an absolute scale. For a specific feature space, preference hypercube and set of searches to fill it one can normalize the FSHC by the largest FSHC value seen and thus calculate the Normalized Feature Space Hypercube Coverage (NFSHC). In the example we have used here the size of the preference hypercube is which is . The largest number of unique feature vectors cells covered, in a (long-running) search using Hill Climbing, was 651, which means that the largest FSHC observed in our experiments was .

A summary of the overall performance of the 10 different methods we investigate can be seen in Table 1. The number of runs per method was 25 except for rand-freq1 where we limited the number of repetitions due to the longer search time.

Method ChoiceModel Runs Coverage std Time Preferred
Table 1: Descriptive statistics on the performance of the 10 investigated methods on the 2-dimensional feature space of string length and number of digits for the ExprGen generator. The ‘Runs’ columns shows the number of runs per method, ‘Coverage’ shows the mean FSHC while ‘std’ is its standard deviation. Finally, ‘Time’ is the mean search time in seconds and ‘Preferred’ is the ratio of samples that is within the preference hypercube.

From the table we see that Hill Climbing performs well but the methods based on random resampling have competitive performance and reach similar levels of coverage. We also see that the NMCS-based methods are generally fast but have worse coverage, regardless if using direct or batch updating of the density. It is also clear that a major determinant of coverage, in addition to the method used, is the choice model. All the methods using the default sampler choice model are at the bottom of the table based on the mean FSHC level reached. A striking example of the difference the choice model can make is for the rand-freq1 method which reaches an average FSHC of with the recursive model at depth 5 while it only reaches with the default sampler choice model. This is a statistically significant difference with a p-value less than based on a Mann-Whitney U-test.

An advantage of using a two-dimensional feature space is that we can visualise in more detail the test data diversity of found by the methods. Figure 1 shows scatterplots for one run each of the three methods hillclimb-4-20 (top), nmcs-4-direct (middle), and rand-once (bottom). These plots draw one point per found test input using a low alpha (transparency) value; thus the darkness of the dot in each cell gives an indication of the density with which the cell was covered. We can see the superior coverage of hill climbing that manages to cover also cells of the hypercube on top where the length of the string (x axis) has medium to low values while the number of digits (y axis) is as high as possible. We can also see that the NMCS search, the middle graph, seems to be constrained in a similar way as the random once method in the bottom graph, i.e. they both have problems to cover the upper parts of the preference hypercube. The NMCS methods are constrained by the base sampler choice model use for the internal simulations.

Figure 1: Scatterplots showing the actual coverage of the preference hypercube (its upper limit is marked with red lines) after 10,000 data were sampled by three different methods: hillclimb-4-20 (top), nmcs-4-direct (middle), and rand-once (bottom).

4.2 Efficiency - Coverage per time

To study the overall efficiency of the tested methods in more detail we can plot the coverage level reached versus the search time expended. Figure 2 shows a scatterplot with the search time in seconds on the (logarithmically scaled) X axis, and the percent of preferred feature space covered (FSHC) on the Y axis. The colour of each point in the graph codes for the method used, so a cloud of points of the same colour represents all the runs of one and the same method. The best position in this graph would be up and on the left meaning a run that both got a high coverage and had a low search time.

Figure 2: Feature space coverage (in % of theoretical maximal feature space size) versus the search time (in seconds) used by a method to reach that coverage. The scale on the X axis is logarithmic

Consistent with the results shown previously we can see that the Hill Climbing method has consistently good results. Even if its variance is larger than for the other methods, signified by the ‘lone’ light orange dot towards the middle of the graph, it tends to be among the fastest optimisers while also reaching the highest coverage levels, on average.

This can be contrasted with the simplest possible strategy, rand-once, in light pink down at the bottom of the graph. Even if, on average, it has similar run times to the fastest methods it fails to even reach 40% coverage.

The NMCS methods all use the default choice model for sampling while traversing the tree of choices. Thus it seems to be hampered by the low coverage of this base model. Even though the NMCS search seems to be able to ‘push out’ from the confines of its base stochastic model, and thus each higher levels of coverage it does not reach as high as the Hill Climber or the methods based on random (re-)sampling of parameters. This makes it clear that NMCS needs a good base model adapted to the task. Alternatively it hints at the possibility to hybridize NMCS by dynamically adapting or randomly sampling the underlying stochastic model.

Figure 2 also gives us an opportunity to better understand what causes long search times for a method. If we look at the three middle point clouds on top, for rand-freq1 (light green, middle right), rand-mfreq5-LHS10 (light purple, middle), and rand-mfreq10-LHS30 (light blue, middle left), we see that they reach roughly the same coverage levels. However, the mfreq10 version takes less than half the search time of the freq1 version to reach that coverage. Since the maxfreq construct will resample a new set of parameter values early if an infeasible datum is generated, time tends to be saved. This is since the infeasible inputs typically arise when the stochastic model is configured to lead to a deep recursion in the number of method calls.

We can see this effect more clearly if we plot the search time for each run versus the percentage of infeasible values sampled during the run. Figure 3 shows that, except for the NMCS methods on the left, there is an almost linear relation between these factors. The smaller but still additional search time increase seen for the rightmost runs in each cluster is probably from the fact that before a deep recursion during generation is interrupted, and an infeasible value returned, there is a large space of non-preferred but still feasible part of the feature space. Generating such test inputs will also take longer than generating shorter inputs with a few levels of recursion. The only real exception to strong correlation seen are the NMCS methods which have a close to 0% of sampled inputs being invalid and still having a relatively high search time. The nature of the NMCS search process is that as soon as one non-preferred datum is generated during the tree-wise ‘pruning’ of choices the whole sub-tree of choices will be deselected; and sub-sequent choices are thus less likely to lead to non-referred or infeasible data.

Figure 3: Search time (in seconds) used by a run versus the percentage of generated test inputs that are infeasible. The colour of the points in the graph are the same as in Figure 2 above so legend excluded here.

4.3 Discussion

Through a set of experiments with 10 different methods to generate diverse test data in specific areas of a defined feature space we have shown that there is not one clearly better method to employ. The results show that a simple hill climbing search was relatively more efficient in covering the preferred parts of the feature space: it covered a larger part of the area in less time. However, random alternatives were not far behind and offer alternative benefits such as less bias. With any search algorithm there is always the risk that one is trading efficiency on one particular set of problems with efficiency in general, over all problems (see for example the ‘No Free Lunch’ theorems by Wolpert and Macready [18]). This can be problematic if the bias leads to the tester missing erroneous behavior of the software under test. However, if a tester really has a reason to want to target a smaller area of the input space a more directed search, such as using a hill climbing search, can be called for.

An important finding in our experiments is about the test data generation tool itself. Even though the Nested Monte Carlo Search (NMCS) has been previously shown by Poulding and Feldt [17] to better target test data with very specific features when we here tried their approach to cover a feature space it is clear that NMCS can be hampered by its underlying stochastic model. All methods we evaluated consistently performed better when using a larger than default stochastic model that gives more detailed control of the generation process. Such models allow for more fine-grained control that can be exploited by the searchers but also used for more efficient ‘blind’ exploration by random sampling. Our experiments thus suggests that the developers of the tool should consider alternative default choices. It also hints that hybridization of the search algorithms with random sampling of a larger stochastic model should be considered in future work. Given our results it is likely that such a hybrid would make it easier for, for example, the NMCS-based methods to break free from the constraints of their current default model.

Somewhat ironically, but in retrospect naturally, the main conclusion is that there is not likely to be a single best method or search algorithm to use for different types of test diversity needs; one needs a toolbox of diverse solutions that needs to be tailored to the diversity goal and situation at hand. This is in line with the argument in [19] that researchers in search-based software engineering should not only consider the basic evolutionary algorithms but should open up to consider a richer set of search and optimisation solutions. In particular this will be important in real-world software testing where there is a need to repeatedly explore the same test input feature space, for example in regression testing scenarios. There we argue that if a model of the mapping from the feature space to the parameter space is built up front, for example using Gaussian Processes as proposed in [19], it can be exploited in later sessions to more quickly generate a diverse set of test data. Future work should, of course, also investigate more test data generation scenarios and evaluate how ability to find real and seeded faults is affected by test data diversity and the size of the feature space from which it is sampled.

5 Conclusions

We have described the feature-specific test diversity problem and investigated how it can be solved with different types of search and sampling approaches. After defining 10 different approaches we evaluated them on a test data generation task for a two-dimensional feature space. Results show that a hill climbing search both gave the best coverage of the target area and was the most efficient (per time step) but that random sampling can be surprisingly effective. The empirical results points to several ways in which the investigated approaches can be improved and, possibly, hybridized to address a diverse set of test data diversity needs. In particular we propose that models that map between feature values and the space being searched can help to ensure test diversity in scenarios of frequent re-testing, such as for regression testing.

Our results also have wider implications for search-based software engineering. Random sampling and, in particular, ways to sample to ensure a better spread over the search space, such as with latin hypercube sampling, can be surprisingly effective in creating diversity. We caution other researchers in search-based software engineering to not blindly reach for a standard search procedure like a genetic algorithm. Depending on the goals for the search and the characteristics of the search and features spaces, non-standard or hybrid methods may be needed and should be considered.


  • [1] R. Feldt, R. Torkar, T. Gorschek, and W. Afzal, “Searching for cognitively diverse tests: Towards universal test diversity metrics,” in Software Testing Verification and Validation Workshop, 2008. ICSTW’08. IEEE International Conference on.   IEEE, 2008, pp. 178–186.
  • [2] N. Alshahwan and M. Harman, “Augmenting test suites effectiveness by increasing output diversity,” in Proceedings of the 34th International Conference on Software Engineering.   IEEE Press, 2012, pp. 1345–1348.
  • [3] R. Feldt, S. Poulding, D. Clark, and S. Yoo, “Test set diameter: Quantifying the diversity of sets of test cases,” in 2016 IEEE International Conference on Software Testing, Verification and Validation (ICST), April 2016, pp. 223–233.
  • [4] Q. Shi, Z. Chen, C. Fang, Y. Feng, and B. Xu, “Measuring the diversity of a test set with distance entropy,” IEEE Transactions on Reliability, vol. 65, no. 1, pp. 19–27, March 2016.
  • [5] R. Feldt and S. Poulding, “Finding test data with specific properties via metaheuristic search,” in Software Reliability Engineering (ISSRE), 2013 IEEE 24th International Symposium on.   IEEE, 2013, pp. 350–359.
  • [6] Y. K. Malaiya, “Antirandom testing: Getting the most out of black-box testing,” in Software Reliability Engineering, 1995. Proceedings., Sixth International Symposium on.   IEEE, 1995, pp. 86–95.
  • [7] T. Y. Chen, H. Leung, and I. Mak, “Adaptive random testing,” in Advances in Computer Science-ASIAN 2004. Higher-Level Decision Making.   Springer, 2004, pp. 320–329.
  • [8] P. Bueno, W. E. Wong, and M. Jino, “Improving random test sets using the diversity oriented test data generation,” in Proceedings of the 2nd international workshop on Random testing: co-located with the 22nd IEEE/ACM International Conference on Automated Software Engineering (ASE 2007).   ACM, 2007, pp. 10–17.
  • [9] H. Hemmati, A. Arcuri, and L. Briand, “Empirical investigation of the effects of test suite properties on similarity-based test case selection,” in Software Testing, Verification and Validation (ICST), 2011 IEEE Fourth International Conference on.   IEEE, 2011, pp. 327–336.
  • [10] A. Panichella, R. Oliveto, M. Di Penta, and A. De Lucia, “Improving multi-objective test case selection by injecting diversity in genetic algorithms,” IEEE Transactions on Software Engineering, vol. 41, no. 4, pp. 358–383, 2015.
  • [11]

    J. K. Pugh, L. B. Soros, and K. O. Stanley, “Quality diversity: A new frontier for evolutionary computation,”

    Frontiers in Robotics and AI, vol. 3, p. 40, 2016.
  • [12] J. Lehman and K. O. Stanley, “Exploiting open-endedness to solve problems through the search for novelty.” in ALIFE, 2008, pp. 329–336.
  • [13] J.-B. Mouret and J. Clune, “Illuminating search spaces by mapping elites,” arXiv preprint arXiv:1504.04909, 2015.
  • [14] B. Marculescu, R. Feldt, and R. Torkar, “Using exploration focused techniques to augment search-based software testing: An experimental evaluation,” in Software Testing, Verification and Validation (ICST), 2016 IEEE International Conference on.   IEEE, 2016, pp. 69–79.
  • [15] J.-S. Park, “Optimal latin-hypercube designs for computer experiments,” Journal of statistical planning and inference, vol. 39, no. 1, pp. 95–111, 1994.
  • [16] T. Cazenave, “Nested monte-carlo search.” in IJCAI, vol. 9, 2009, pp. 456–461.
  • [17] S. Poulding and R. Feldt, “Generating structured test data with specific properties using Nested Monte-Carlo Search,” in Proc. Genetic and Evolutionary Computation Conference (GECCO), 2014, pp. 1279–1286.
  • [18] D. H. Wolpert and W. G. Macready, “No free lunch theorems for optimization,” IEEE transactions on evolutionary computation, vol. 1, no. 1, pp. 67–82, 1997.
  • [19] R. Feldt and S. Poulding, “Broadening the search in search-based software testing: it need not be evolutionary,” in Search-Based Software Testing (SBST), 2015 IEEE/ACM 8th International Workshop on.   IEEE, 2015, pp. 1–7.