<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Predicting Test Case Verdicts Using Textual Analysis of Committed Code Churns</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Chalmers j University of Gothenburg</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Computer Science</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Engineering</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department</institution>
          ,
          <addr-line>Gothenburg</addr-line>
          ,
          <country country="SE">Sweden</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2081</year>
      </pub-date>
      <fpage>138</fpage>
      <lpage>153</lpage>
      <abstract>
        <p>Background: Continuous Integration (CI) is an agile software development practice that involves producing several clean builds of the software per day. The creation of these builds involve running excessive executions of automated tests, which is hampered by high hardware cost and reduced development velocity. Goal: The goal of our research is to develop a method that reduces the number of executed test cases at each CI cycle. Method: We adopt a design research approach with an infrastructure provider company to develop a method that exploits Machine Learning (ML) to predict test case verdicts for committed source code. We train ve di erent ML models on two data sets and evaluate their performance using two simple retrieval measures: precision and recall Results: While the results from training the ML models on the rst data-set of test executions revealed low performance, the curated dataset for training showed an improvement on performance with respect to precision and recall. Conclusion: Our results indicate that the method is applicable when training the ML model on churns of small sizes.</p>
      </abstract>
      <kwd-group>
        <kwd>Machine Learning</kwd>
        <kwd>Verdicts</kwd>
        <kwd>Code Churn</kwd>
        <kwd>Test Case Selection</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Meding2</p>
    </sec>
    <sec id="sec-2">
      <title>Introduction</title>
      <p>
        CI is a modern software development practice, which is based on frequent
integration of codes from developers and teams into a product's main branch [
        <xref ref-type="bibr" rid="ref23">23</xref>
        ].
One of the cornerstones of its popularity is the promise of higher quality
delivered by frequent testing and the ability to quickly pinpoint the code that does
not meet quality requirements. To achieve this, CI systems execute tests as part
of the integration [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. However, excessive execution of automated software tests
is penalized with high hardware cost and reduced development velocity that may
consequently hinder agility and time to market.
      </p>
      <p>In order to address this challenge, a CI system should be able to pinpoint
exactly which test cases should be executed in order to maximize the probability
Copyright © 2019 for this paper by its authors.</p>
      <p>Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
of nding defects (i.e. to reduce the \empty" test executions). To achieve this,
the CI system needs to be able to predict whether a given test case has a chance
of nding a defect or not, or at least whether it will fail or pass { predict the
verdict of a test case execution.</p>
      <p>We set o to address the problem of predicting test case verdicts by training
ve ML models on a large data set of historical test cases that were executed
against changes made to a software developed at company A. The term "code
churn" is de ned as a measure that quanti es these changes. Throughout the
remaining sections of this paper, we use this term to refer to committed code
made during di erent CI cycles.</p>
      <p>
        Our research is inspired from a previous study conducted by Knauss et el.
[
        <xref ref-type="bibr" rid="ref13">13</xref>
        ], where the authors explored the relationship between historical code churns
and test case executions using a statistical model. Their method used precision
and recall metrics in predicting an optimal suite of functional regression tests
that would trigger failure. In this paper we expand on that approach by
going one step further { conducting a textual analysis of what is the code that
is actually being integrated. For example, instead of using code location as the
parameter, we use such measures as the number of 'if' statements or whether
the code contains data de nitions. Similarly, our choice of using code churns
is inspired from the work of Nagappan and Ball [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], in which the authors
presented a technique for early faults prediction using code churn measures. In their
publication, the authors identi ed a positive correlation between the size of code
churns and system defects density. Our method builds on this and uses the Bag of
Words (BOW) approach to extract features from code churns. This enables the
identi cation of statistical dependency between keywords and test case verdicts.
For example, a churn containing a frequent occurrence of keywords like new or
delete might trigger speci c tests to fail. More precisely, we aim at investigating
the following research question:
      </p>
      <p>How to reduce the number of executed test cases by selecting the most
e ective minimal test suite when integrating new code churns into the
product's main branch?</p>
      <p>Our study was conducted in collaboration with a large Swedish-based
infrastructure providing company. We study a software product that has evolved over
a span of a decade by di erent cross functional teams. As a result of our study,
we present a method that uses ML to predict test case verdicts (MeBoTS).</p>
      <p>
        To address this research question, we conduct a design research study, where
we develop a new method and evaluate it on the company's data set. Our method
is based on the research by Ochodek et al. [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ], which uses textual analyses to
characterize source code. Our MeBoTS method builds on that by using historical
test verdicts as predicted variables and uses Random Forest algorithms to make
the predictions.
      </p>
      <p>The remainder of this paper is organized as follows: Section II provides
background information about two categories of ML. The sections that follow
provide: an overview of the most related studies in this area, a description of the
method that we developed in our study as well as the results, validity analysis,
recommendations, and nally, conclusion.
2
2.1</p>
    </sec>
    <sec id="sec-3">
      <title>Background</title>
      <sec id="sec-3-1">
        <title>Categories of Machine Learning</title>
        <p>
          Machine learning is a class of Arti cial Intelligence that provides systems the
ability to automatically make inferences, given examples relevant to a task [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ].
The main advantage of using Machine learning over classical statistical analysis,
is its ability to deal with large and complex data-sets [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. These systems can be
classi ed into four categories depending on the type of supervision involved in
training: a) Supervised, b) Unsupervised, c) Semi-supervised, d) Reinforcement
Learning [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. Since we view the problem of predicting test case verdicts as a
classi cation problem, we brie y mention the supervised learning category.
        </p>
        <p>
          In supervised learning the training data-set fed into the ML model contains
the desired solution, called labels. The model tries to nd a statistical structure
between these examples and their desired solutions [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. A typical task for this
kind of learning is classi cation.
2.2
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>Tree-based and Deep Learning Models</title>
        <p>
          In Machine learning, a decision tree is an algorithm that belongs to the family
of supervised learning algorithms. The algorithm has an inherent tree-like
structure and is commonly used for solving classi cation and regression problems
[
          <xref ref-type="bibr" rid="ref20">20</xref>
          ]. Starting from the root node, the algorithm uses a binary recursive scheme
to repeatedly split each node into two child nodes, where the root node has the
complete training sample [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. The resulting child nodes correspond to features
in the training data, whereas the leaf nodes correspond to class labels (binary or
multivariate). Other algorithms, such as Random Forest and Adaptive Boosting,
use Decision trees as a primary component in their structure. These algorithms
build a collection of decision trees, called an ensemble, to increase the overall
learning of the classi cation or regression task at hand [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ].
        </p>
        <p>
          Deep Learning is a branch of ML that was founded on the premise of using
successive learning "layers" to achieve more useful representation of the data
[
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. The learning of these successive layers are achieved via models called
Neural Networks (NN) [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. A multilayer NN is one that consists of at least three
layers: 1) one input layer, 2) at least one hidden layer, 3) and an output layer
of arti cial neurons [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. Similarly, a Convolutional network (CNN) consists of
a set of learning layers [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. The main di erence between the two networks is in
the way they search for patterns in the input space [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. More precisely, a CNN
works by sweeping a matrix-like window, called lter, over every location in
every patch to extract patterns from the input data [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. As opposed to Decision
Trees, ANN have a black box nature, which means that no insight about how
their predictions were made can be easily accessible [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. Nevertheless, the main
advantage of using deep learning comes from their ability to handle large and
complex data-sets of features.
2.3
        </p>
      </sec>
      <sec id="sec-3-3">
        <title>Code Churns</title>
        <p>
          The amount of changes made to software over time is referred to as code churn
[
          <xref ref-type="bibr" rid="ref14">14</xref>
          ]. As new churns are added, new risks of introducing defects into the system
emerge [
          <xref ref-type="bibr" rid="ref21">21</xref>
          ]. According to Y. Shin et al. [
          <xref ref-type="bibr" rid="ref21">21</xref>
          ], each check-in made into a version
control system includes newly added or deleted code that increase the chances
of triggering failures. At some point in time, an evolving system may be
vulnerable, on average, to one extra fault for every new additional change [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]. For
example, in C programming, the declaration of 'static' local and global variables
are among the most confused keywords by developers, as each static local and
global declaration has a di erent e ect on how the data will be retained in the
program's memory [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ].
3
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Related Work</title>
      <p>In the following we discuss related work on the speci c use of machine learning
for test case selection or prioritization.
3.1</p>
      <sec id="sec-4-1">
        <title>ML-based Test-Case Selection</title>
        <p>
          Around 2015/16, we nd the rst machine learning based approaches for
testcase selection. With only 4 studies included in the systematic mapping study by
Durelli et al. [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ], the use of machine learning for test case prioritization seems
to be new.
        </p>
        <p>
          Busjaeger and Xie [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ] present an industrial case study in which a linear model
is trained with the SVMmap algorithm using the features Java code coverage,
text path similarity, text content similarity, failure history, and test age. The
evaluation on the industrial case study, considering 2000 changes and over 45 000
test executions shows an Average Percentage of Faults Detected (APFD) of
around 85%.
        </p>
        <p>
          Chen et al. [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ] prioritize test programs for compilers "identi es a set of
features of test programs, trains a capability model to predict the probability of a
new test program for triggering compiler bugs and a time model to predict the
execution time of a test program."
        </p>
        <p>
          Spieker et al. [
          <xref ref-type="bibr" rid="ref22">22</xref>
          ] introduced Retecs, a reinforcement learning-based approach
to test case selection and prioritization. Retecs considers duration of a test case's
execution, previous last execution and failure history. Online learning is used to
improve test case selection between continuous integration cycles. The approach
was evaluated on 3 industrial data sets, including together more than 1.2
million verdicts, and achieved a normalized Average Percentage of Faults Detected
(APFD) of around 0.4 to 0.8 depending on the data set.
        </p>
        <p>
          Most recently, Azizi and Do [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] perform test case prioritization by calculating
a ranked list of components considering the access frequency of a component as
well as a fault risk. The fault risk for each component is thereby predicted using
a linear model of change and bug histories. Test cases associated with highly
ranked components are prioritized. The approach was evaluated on three
webbased systems and where it could reduce the number of test cases by 20% while
still nding over 80% of the errors.
        </p>
        <p>
          Palma et al. [
          <xref ref-type="bibr" rid="ref18">18</xref>
          ] replicate and extend a work of Noor and Hemmati [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ] and
[
          <xref ref-type="bibr" rid="ref15">15</xref>
          ], to predict test case failure based on a machine learned model basing on test
quality metrics as well as similarity-based metrics.
        </p>
        <p>
          However, to the best of our knowledge, no other learning-based method
works for code-churns. The only exception is one of our previous collaboration
with Knauss et al. [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ]. The introduced code-churn based test selection method
(CCTS) analyzes correlations between test-case failure and source code change.
The approach was evaluated in several con gurations, leading to results
ranging from 26% precision up to a 54% with a 97% recall. We deem these results
promising and one of the main motivations for this study.
4
        </p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Method using Bag of Words for Test Selection (MeBoTS)</title>
      <p>
        The following section is a description of the MeBoTS method used in this
research, which comprises of three sequential steps, as shown in Figure 1. The
method utilizes two Python programs and an open source textual analyzer
program, called CCFLEX [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ].
A Python-based code churn extraction program was created to collect and
compile code churns committed in the source code repository. The program takes
one input parameter: a time ordered list of historical test case execution results
extracted from a database, where each element in the list represents an instance
of a previously run test case and holds information about: the name of the
executed test case, the baseline code in Git against which the test case was executed,
and the verdict value - as shown in Table 1.
      </p>
      <p>The program rst loops through the extracted list of tests and looks at the
change history log maintained by Git and performs a le comparison utility (di )
on a pair of consecutive baselines in the tests list. Note that each baseline value
is a hash representation of a revision (build), pointing to a speci c location in
Git's history log. The result is a ne-grained string that comprises the committed
code churns, where each LOC in the churn is compiled with its: 1) lename, 2)
physical le path, 3) test case verdict, 4) baseline hash code.</p>
      <p>The resulting string is then arranged in a table-like format and written in a
csv le, named as 'Lines of Code' in Figure 1.
4.2</p>
      <sec id="sec-5-1">
        <title>Textual Analysis and Features Extraction (Step 2)</title>
        <p>The result of the extract from Git is saved as an array (code churn, lename,
physical le path, test case verdict and baseline). This le is the input to our
textual analysis and feature extraction. The textual analysis and feature extraction
use each line from the code churn and:
{ creates a vocabulary for all lines (using the bag of words technique, with a
speci c cut-o parameter),
{ for the words that are used seldom (i.e. fall outside of the frequency de ned
by the cut-o parameter of the bag of words), a token is created,
{ nds a set of prede ned keywords in each line,
{ check each word in the line whether it is part of the vocabulary, it should be
tokenized or if it is a prede ned feature.</p>
        <p>An example input is presented in Table 2. The input contains an example
code in C.</p>
        <p>For the textual analyses, we can pre-de ne (arbitrarily for this example)
two features: \if" and \int". The bag of words analysis also found the word
\printf" as frequent. It has also de ned the following tokens:
{ \a" { to denote the words (of any length) that contain only lowercase letters
(e.g. \condition"),
{ \Aa" { to denote the words that start with capital letters and continue with
lowercase letters (e.g. \Hello"),
{ \0" { to denote the numbers, i.e. sequence of numbers of any length (e.g.
\10")</p>
        <p>The manual features and the bag of words results are then used as features
in the feature extraction. Table 3, which corresponds to the input from Table 2.</p>
        <p>
          Table 3 is a large array with the numbers, each representing the number of
times a speci c feature presents in the line. This way of extracting information
about the source code is new in our approach, compared to the most common
approaches of analyzing code churns. Compared to the other approaches, MeBoTS
recognizes what is written in the code, without understanding of the syntax or
semantics of the code. This means that we can analyze each line of code
separately, without the need to compile the code or without the need to parse it.
This means, that we can take code churns from di erent les in the same
baseline and analyze them together. MeBoTS also goes beyond such approaches like
Nagappan et al. [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ], which characterizes churns in terms of metrics like number
of churned lines or churn size.
4.3
        </p>
      </sec>
      <sec id="sec-5-2">
        <title>Training and Applying the Classi er Algorithm (Step 3)</title>
        <p>We exploit the set of extracted features provided by the textual analyzer in
step 2 as the independent variables and the verdict of the executed test cases
as the dependant variable, which is a binary representation of the execution
result (passed or failed). The MeBoTS method uses a second Python program
that utilizes and trains an ML model to classify test case verdicts. The program
reads the BOW vector space le in a sequence of chunks, merging the extracted
feature vectors and the verdicts vector into a single data frame that gets split
into a training and testing set before it is fed into the models for training. Table
4 shows an excerpt of the generated data frame.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Research Design</title>
      <sec id="sec-6-1">
        <title>Collaborating Company</title>
        <p>The study has been conducted at an organization, belonging to a large
infrastructure provider company. The organization develops a mature software-intensive
telecommunication network product. The organization consists of several
hundred software developers, organized in several empowered agile teams, spread
over a number of continents. Given that they have been early adopters of lean
and agile software development methodologies, they have become mature in these
areas of work. They have also implemented CI and continuous deliveries.</p>
        <p>The organization is also mature with regard to measuring. For instance every
agile team, as well as leading functions/roles, uses one or more monitors to
display status and progress in various development and devops areas. A
wellestablished and e cient measurement infrastructure, automatically collects and
processes data, and then distributes the information needed by the organization.
5.2</p>
      </sec>
      <sec id="sec-6-2">
        <title>Dataset</title>
        <p>The data-set provided by company A contained historical test case execution
results for a mature software product that has evolved for almost a decade. The
analyzed product consisted of over 10k test cases and several million lines of code
written in the C language. We decided to test the MeBoTS on a set of randomly
selected tests that, presumably, reacted to changes in the source code during
di erent CI cycles. Our selection of test cases was based on the granularity of
test executions whose verdicts changed from one state to another(see Table 1).</p>
        <p>The extracted data-set belonged to twelve test cases that were executed 82
times during di erent CI cycles. The size of the extracted churns was 1.4 million
lines of code, among which 618k lines were labeled as passed and 776k as failed.
To better understand the shape of the data-set, we visually inspected the size of
code churns covered by each test execution. The scatter plot in Figure 2 shows
the distribution of the 82 extracted test executions, belonging to the twelve test
cases. Each mark on the plot represents one test case execution. The x-axis
represents the number of lines in the code churn the test case was executed on.
The y-axis represents the overall number of test executions for the executed test
case. Test executions of the same test case are marked with the same symbol.
The visual inspection of the scatter plot suggests that our data-set comprised
of churns of varying sizes (large and small). We interpreted this distribution
with uncertainty of whether large churns contain additional noise that would
adversely a ect the training of the ML models. As a result, we decided to curate
the original data-set by ltering out tests that were executed on churns whose
total size exceeded 110k lines. The visual inspection of the curated data-set
is represented in Figure 3, comprised of 290k lines of code, containing a fairly
balanced representation of the binary classes (passed and failed), with 110k lines
belonging to the passed class and 180k lines belonging to the failed class.</p>
        <p>The two data-sets described above were used for training the ML models.
The rst data-set was used in the rst phase, whereas the second curated
dataset was used in the second phase of ML training, and ultimately became our
focus due to data size homogeneity.
5.3</p>
      </sec>
      <sec id="sec-6-3">
        <title>Evaluating and Selecting a Classi cation Model</title>
        <p>To select the most suitable model for classifying test verdicts, we selected ve
di erent ML models and trained them sequentially. The ve models are: 1)
Decision Tree, 2) Random Forest, 3) AdaBoost, 4) Multilayer NN, 5) CNN</p>
        <p>The choice of selecting the three tree-based models was due to their low
computational cost and white box nature, whereas the selection of ANN models
were based on their ability to abstract large and complex number of features.</p>
        <p>Each of the ve classi cation models for test verdicts uses i) the historical test
case verdicts ii) the feature vectors in the bag of words table as the baseline of
prediction. The evaluation was done in two iterations. In the rst iteration, the
ve models were trained on the original data-set, which contained a mix of large
and small churns, comprising a total of 1.4m lines of code for 500 feature vectors.
The second iteration involved training the models on the curated data-set, which
almost contained 290k lines for the same 500 features, as in the rst iteration.
Both data sets, curated and original, were split as follow: 70% for the training
set and 30% for the test set.</p>
        <p>
          To save the long run time required by automated hyper-parameter tuning
tools such as grid and random search, the con guration of the models was done
manually. Table 5 summarizes the hyper-parameters used for training the
models. We used the implementation of Decision Tree, Random Forest, and
AdaBoost algorithms available in the Python scikit-learn library [
          <xref ref-type="bibr" rid="ref19">19</xref>
          ] and then used
the Keras library [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ] for the implementation of Multilayer NN and CNN.
        </p>
        <p>The hyper-parameters of the three tree-based models were kept in their
default state as found in the scikit-learn library. The only alterations made were in
the 'random state' value in Decision Trees and the n estimator (number of trees)
in both Adaboost and Random Forest. With respect to the ANN models, the
architecture of the multilayer ANN was represented with three sequential dense
layers that consisted of: one input layer, one hidden layer, and one output layer.
For the CNN, the stack of layers comprised of: a Reshape layer, a Convolution
layer, a Maxpooling layer, and four Dense layers. The learning in both models
was induced over 100 epochs (iterations), as can be seen in table 5</p>
        <p>The performance of the classi ers were evaluated using simple retrieval
measure: recall and precision.</p>
        <p>These measures are based on the following four categories of errors:
{ True positives: correct prediction of test executions that pass
{ True negatives: correct prediction of test executions that fail
{ False positives: incorrect prediction of test executions that pass
{ False negatives: incorrect prediction of test executions that fail
Precision is the number of correctly predicted tests divided by the total number
of predicted tests, calculated as follows:
precision =</p>
        <p>jT rueP ositivej
jT rueP ositivej + jF alseP ositivej
Recall is the number of correctly predicted tests divided by the total number of
tests that should have been positive.</p>
        <p>recall =</p>
        <p>jT rueP ositivej
jT rueP ositivej + jF alseN egativej
While recall and precision measures relate to one another, precision is a
measure of exactness, whereas recall is a measure of completeness indicating the
percentage of all predicted failed tests in our case. Since the goal of this study
is to reduce the amount of test executions without altering the e ectiveness of
testing, we needed to minimize the risk of missing tests that will actually fail
and, therefore, accept some false alarms in the prediction of failed tests. Thus,
we believe that the measure of the mode's precision is more important than its
recall.
6</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>Results</title>
      <p>To answer the research question, we present the results of using MeBoTS for
predicting test case verdicts. We interpret the results of the analysis in light of
the reported rates of precision and recall and the values of the four categories
of errors: true negatives, false positives, false negatives, and true negatives, as
shown in Tables 6 and 7 list the results of training the ve models using the
original and curated data sets.
6.1</p>
      <sec id="sec-7-1">
        <title>Training the Models on Churns of Varying Sizes</title>
        <p>The evaluation of the ve models in the rst iteration reports a mean
precision of 47% and a mean recall of 17%, suggesting that all models achieved low
performance. The best result was obtained by the Multilayer NN model with a
precision rate of 50.3% and a recall rate of 31%. The precision and recall rates
for the ve models can be seen in Figure 4. The interpretation of these values
suggest that out of the 406,948 lines of code that actually triggered a test case
failure, the model correctly predicted test failure for 226,994 lines, whereas it
could correctly predict a passing test verdict for 5,758 out of 11,428 lines.
Similarly, the results of the four categories of errors for the other models can be seen
in Table 6 and interpreted in the same fashion.</p>
        <p>Model
Decision Trees
Random Forest</p>
        <p>AdaBoost
Multilayer NN</p>
        <p>CNN</p>
      </sec>
      <sec id="sec-7-2">
        <title>Training the Models on Churns of Small Sizes</title>
        <p>The second iteration of analysis involved training the same set of models on the
curated data-set, which excluded tests covering churns with quantities above
110k lines of code. The results, shown in Figure 5, indicate an improvement in
precision and recall when compared to the results in the rst iteration for the
same types of models. Table 7 reports the results from the second round of
training, showing a mean precision of 70% and a mean recall of 44.5%. The Multilayer
NN model performed best in prediction, such that, it correctly predicted 48,755
lines that actually triggered a test case failure, out of 67,363 lines in the test set.</p>
        <p>Model
Decision Trees
Random Forest</p>
        <p>AdaBoost
Multilayer NN</p>
        <p>
          CNN
The results show that we can predict the verdict of a test case with a precision
of 73.3%. This means that we can use the results to reduce the test suite by
excluding tests that are predicted to pass, but we need to know that there is
26.7% probability that we miss a test case failure. This means that the reduction
of the test suite comes with a cost. This cost can be reduced, for example, if we
collect the test cases which were not executed and execute them with lower
frequency (e.g. during a nightly test suite instead of hourly builds).
When analyzing the validity of our study, we used the framework recommended
by Wohlin et al. [
          <xref ref-type="bibr" rid="ref24">24</xref>
          ]. We discuss the threats to validity in two categories:
internal and external. Typically, a number of internal threats to validity emerge
in studies that involve designing an ANN architecture, namely that the
number of hyper-parameters to tune is large that we cannot cover all combinations
to decide on the best con guration for the network. To minimize this threat,
we used two di erent multilayer neural networks and trained them during the
two iterations of analysis. This provided us with a sanity check on whether the
networks produce similar results. Another threat to internal validity is in the
random selection of test cases. There is a chance that the extracted test
executions contain one or more test that failed due to factors that do not pertain
to functional de ciencies, but due to, for instance, an environment upgrade or
machinery failure at execution time. Similarly, there is a chance that the
extracted test executions may have failed as a result of defects in the test script
code and not the base code. In order to minimize this threat, we collected data
for multiple test cases, thus minimizing the probability of identifying test cases
which are not representative.
        </p>
        <p>The major threat to external validity for this study comes from the number
of extracted tests that were used for training the classi ers. We only studied one
company and one product and a limited number of test cases. This was a design
choice as we wanted to understand the dynamics of test execution and be able
to use statistical methods alongside the machine learning algorithms. However,
we are aware that the generalization of the results for di erent types of systems
require further investigations using tests and churns from di erent systems.
8</p>
      </sec>
    </sec>
    <sec id="sec-8">
      <title>Recommendations</title>
      <p>In this section, we provide our recommendations for practitioners who would like
to utilize MeBoTS for early prediction of test case verdicts.</p>
      <p>{ The choice of using deep learning or tree-based models for solving this
supervised ML problem does not lead to better prediction performance. For
this reason, we suggest the use of Decision Trees, since they require less
computational time and provide knowledge as to how the results of classi cation
were derived.
{ We suggest to only utilize code churns that are homogeneous and small
in size prior to applying features extraction with BOW. Small code churns
introduce less noise and therefore the quality of the predictions is higher.</p>
      <p>This can also save practitioners ample time for data curation.
{ We recommend that practitioners only extract historical test executions that
have failed due to reasons related to functional defects for training the ML
model. This knowledge can be obtained from testers/developers who are
familiar with the recurrent issues in the source code.
9</p>
    </sec>
    <sec id="sec-9">
      <title>Conclusion and Future Work</title>
      <p>This paper has presented a method (MeBoTS) for achieving early prediction
of test case verdicts by training a machine learning model on historical test
executions and code churns. We have evaluated the method using two data sets,
one containing a variation of large and small churns, and a second containing only
small churns. The results from training the models on small churns revealed a
precision rate of 73% and a recall of 43.6%, suggesting that the application of the
method is promising, yet more investigation is required to validate the ndings.
Moreover, contrary to other existing methods that use statistical correlations for
predicting test verdicts, the main advantage of MeBoTS is the ability to predict
verdicts of new code changes as they emerge during development and before they
get integrated into the main branch.</p>
      <p>We believe that the results of this study open new directions for studies to
investigate the e ectiveness of MeBoTS on di erent types of systems using larger
set of small churns with more test case executions. Finally, studies that
investigate the impact of using di erent feature extraction techniques, such as word
embedding are encouraged to identify any changes in the overall performance of
MeBoTS.</p>
    </sec>
    <sec id="sec-10">
      <title>Acknowledgment</title>
      <p>This research has been partially carried out in the Software Centre, University
of Gothenburg, and Ericsson AB.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Awad</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Khanna</surname>
          </string-name>
          , R.:
          <article-title>E cient learning machines: theories, concepts, and applications for engineers and system designers</article-title>
          .
          <source>Apress</source>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Azizi</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Do</surname>
          </string-name>
          , H.:
          <article-title>A collaborative ltering recommender system for test case prioritization in web applications</article-title>
          .
          <source>In: Proceedings of the 33rd Annual ACM Symposium on Applied Computing</source>
          . pp.
          <volume>1560</volume>
          {
          <fpage>1567</fpage>
          . SAC '18,
          <string-name>
            <surname>ACM</surname>
          </string-name>
          , New York, NY, USA (
          <year>2018</year>
          ). https://doi.org/10.1145/3167132.3167299, http://doi.acm.
          <source>org/10</source>
          .1145/3167132.3167299
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Beningo</surname>
          </string-name>
          , J.:
          <article-title>Using the static keyword in c</article-title>
          . https://community.arm.com/developer/ip-products/system/b/embeddedblog/posts/using
          <article-title>-the-static-keyword-in-</article-title>
          <string-name>
            <surname>c</surname>
          </string-name>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Busjaeger</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xie</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>Learning for test prioritization: an industrial case study</article-title>
          .
          <source>In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering</source>
          . pp.
          <volume>975</volume>
          {
          <fpage>980</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Calikli</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Staron</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Meding</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          :
          <article-title>Measure early and decide fast: transforming quality management and measurement to continuous deployment</article-title>
          .
          <source>In: Proceedings of the 2018 International Conference on Software and System Process</source>
          . pp.
          <volume>51</volume>
          {
          <fpage>60</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Chen</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bai</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hao</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xiong</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhang</surname>
          </string-name>
          , H.,
          <string-name>
            <surname>Xie</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Learning to prioritize test programs for compiler testing</article-title>
          .
          <source>In: Proceedings of the 39th International Conference on Software Engineering</source>
          . pp.
          <volume>700</volume>
          {
          <fpage>711</fpage>
          . IEEE Press (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Chollet</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          , et al.: Keras. https://keras.io (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Chollet</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          :
          <article-title>Deep Learning with Python</article-title>
          .
          <source>Manning</source>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Durelli</surname>
            ,
            <given-names>V.H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Durelli</surname>
            ,
            <given-names>R.S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Borges</surname>
            ,
            <given-names>S.S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Endo</surname>
            ,
            <given-names>A.T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Eler</surname>
            ,
            <given-names>M.M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dias</surname>
            ,
            <given-names>D.R.</given-names>
          </string-name>
          , Guimara~es,
          <string-name>
            <surname>M.P.:</surname>
          </string-name>
          <article-title>Machine learning applied to software testing: A systematic mapping study</article-title>
          .
          <source>IEEE Transactions on Reliability</source>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Gondra</surname>
            ,
            <given-names>I.:</given-names>
          </string-name>
          <article-title>Applying machine learning to software fault-proneness prediction</article-title>
          .
          <source>Journal of Systems and Software</source>
          <volume>81</volume>
          (
          <issue>2</issue>
          ),
          <volume>186</volume>
          {
          <fpage>195</fpage>
          (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Graves</surname>
            ,
            <given-names>T.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Karr</surname>
            ,
            <given-names>A.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marron</surname>
            ,
            <given-names>J.S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Siy</surname>
          </string-name>
          , H.:
          <article-title>Predicting fault incidence using software change history</article-title>
          .
          <source>IEEE Transactions on Software Engineering</source>
          <volume>26</volume>
          (
          <issue>7</issue>
          ),
          <volume>653</volume>
          {
          <fpage>661</fpage>
          (
          <year>July 2000</year>
          ). https://doi.org/10.1109/32.859533
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Gron</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Hands-On Machine Learning with Scikit-Learn and TensorFlow</article-title>
          .
          <string-name>
            <surname>Oreilly</surname>
          </string-name>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Knauss</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Staron</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Meding</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          , Soder,
          <string-name>
            <given-names>O.</given-names>
            ,
            <surname>Nilsson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Castell</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          :
          <article-title>Supporting continuous integration by code-churn based test selection</article-title>
          .
          <source>In: Proceedings of the Second International Workshop on Rapid Continuous Software Engineering</source>
          . pp.
          <volume>19</volume>
          {
          <fpage>25</fpage>
          . IEEE Press (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Nagappan</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ball</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>Use of relative code churn measures to predict system defect density</article-title>
          .
          <source>In: Proceedings of the 27th international conference on Software engineering</source>
          . pp.
          <volume>284</volume>
          {
          <fpage>292</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Noor</surname>
            ,
            <given-names>T.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hemmati</surname>
          </string-name>
          , H.:
          <article-title>A similarity-based approach for test case prioritization using historical failure data</article-title>
          .
          <source>In: 2015 IEEE 26th International Symposium on Software Reliability Engineering (ISSRE)</source>
          . pp.
          <volume>58</volume>
          {
          <fpage>68</fpage>
          .
          <string-name>
            <surname>IEEE</surname>
          </string-name>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Noor</surname>
            ,
            <given-names>T.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hemmati</surname>
          </string-name>
          , H.:
          <article-title>Studying test case failure prediction for test case prioritization</article-title>
          .
          <source>In: Proceedings of the 13th International Conference on Predictive Models and Data Analytics in Software Engineering</source>
          . pp.
          <volume>2</volume>
          {
          <fpage>11</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>Ochodek</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Staron</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bargowski</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Meding</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hebig</surname>
            ,
            <given-names>R.:</given-names>
          </string-name>
          <article-title>Using machine learning to design a exible loc counter</article-title>
          .
          <source>In: Machine Learning Techniques for Software Quality Evaluation (MaLTeSQuE)</source>
          , IEEE Workshop on. pp.
          <volume>14</volume>
          {
          <fpage>20</fpage>
          .
          <string-name>
            <surname>IEEE</surname>
          </string-name>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <surname>Palma</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Abdou</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bener</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maidens</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , Liu,
          <string-name>
            <surname>S.:</surname>
          </string-name>
          <article-title>An improvement to test case failure prediction in the context of test case prioritization</article-title>
          .
          <source>In: Proceedings of the 14th International Conference on Predictive Models and Data Analytics in Software Engineering</source>
          . pp.
          <volume>80</volume>
          {
          <fpage>89</fpage>
          . PROMISE'18,
          <string-name>
            <surname>ACM</surname>
          </string-name>
          , New York, NY, USA (
          <year>2018</year>
          ). https://doi.org/10.1145/3273934.3273944, http://doi.acm.
          <source>org/10</source>
          .1145/3273934.3273944
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <surname>Pedregosa</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Varoquaux</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gramfort</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Michel</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Thirion</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grisel</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Blondel</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Prettenhofer</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weiss</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dubourg</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vanderplas</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Passos</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cournapeau</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Brucher</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Perrot</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Duchesnay</surname>
          </string-name>
          , E.:
          <article-title>Scikit-learn: Machine learning in Python</article-title>
          .
          <source>Journal of Machine Learning Research</source>
          <volume>12</volume>
          ,
          <volume>2825</volume>
          {
          <fpage>2830</fpage>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          20.
          <string-name>
            <surname>Saxena</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          :
          <article-title>Introduction to decision tree algorithm (</article-title>
          <year>2017</year>
          ), https://dataaspirant.com/
          <year>2017</year>
          /01/30/how
          <article-title>-decision-tree-algorithm-works/</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          21.
          <string-name>
            <surname>Shin</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Meneely</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Williams</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Osborne</surname>
            ,
            <given-names>J.A.</given-names>
          </string-name>
          :
          <article-title>Evaluating complexity, code churn, and developer activity metrics as indicators of software vulnerabilities</article-title>
          .
          <source>IEEE Transactions on Software Engineering</source>
          <volume>37</volume>
          (
          <issue>6</issue>
          ),
          <volume>772</volume>
          {787 (Nov
          <year>2011</year>
          ). https://doi.org/10.1109/TSE.
          <year>2010</year>
          .81
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          22.
          <string-name>
            <surname>Spieker</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gotlieb</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marijan</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mossige</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Reinforcement learning for automatic test case prioritization and selection in continuous integration</article-title>
          .
          <source>In: Proceedings of the 26th ACM SIGSOFT International Symposium on Software Testing and Analysis</source>
          . pp.
          <volume>12</volume>
          {
          <fpage>22</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref23">
        <mixed-citation>
          23.
          <string-name>
            <surname>Stahl</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bosch</surname>
          </string-name>
          , J.:
          <article-title>Experienced bene ts of continuous integration in industry software product development: A case study</article-title>
          .
          <source>In: The 12th IASTED International Conference on Software Engineering</source>
          ,(Innsbruck, Austria,
          <year>2013</year>
          ). pp.
          <volume>736</volume>
          {
          <issue>743</issue>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref24">
        <mixed-citation>
          24.
          <string-name>
            <surname>Wohlin</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Runeson</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          , Host,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Ohlsson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.C.</given-names>
            ,
            <surname>Regnell</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            ,
            <surname>Wesslen</surname>
          </string-name>
          ,
          <string-name>
            <surname>A.</surname>
          </string-name>
          :
          <article-title>Experimentation in software engineering</article-title>
          . Springer Science &amp; Business
          <string-name>
            <surname>Media</surname>
          </string-name>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>