IPA Fall Days 2019

Annibale Panichella
Annibale PanichellaAssistant Professor at Delft University of Technology
Automated Test Generation for
Unit Testing and Beyond
Annibale Panichella
a.panichella@tudelf.nl
@AnniPanic
1
Unit Testing
2
class Triangle {
int a, b, c; //sides
String type = "NOT_TRIANGLE";
Triangle (int a, int b, int c){…}
void computeTriangleType() {
1. if (a == b) {
2. if (b == c)
3. type = "EQUILATERAL";
else
4. type = "ISOSCELES";
} else {
5. if (a == c) {
6. type = "ISOSCELES";
} else {
7. if (b == c)
8. type = “ISOSCELES”;
else
9. type = “SCALENE”;
}
}
}
Class Under Test (CUT)
@Test
public void test(){
// Constructor (init)
// Method Calls
// Assertions (check)
}
Test Case
@Test
public void test(){
Triangle t = new Triangle (1,2,3);
t.computeTriangleType();
String type = t.getType();
assertTrue(type.equals(“SCALENE”));
}
3
Is it that Easy?
Class = Pass2Verifier.java
Project = Apache commons BCEL
How to Generate Tests in
Reasonable Time?
4
Search-Based Software Testing
5
Computational
Intelligence
Software_
Testing_
Search
Based
Software
TestingOptimization Search
Genetic Algorithms
Ant Colony
Test Case
Coverage
Assertions
Failures
Search-Based Software Testing
6
Computational
Intelligence
Software_
Testing_
AI-based
Software
Testing
Artificial Intelligence?
7
[Domingos2015 “The Master Algorithm”]
Neural Network
Regression
Support Vector
Tribe Origin Master Algorithm
Symbolists Logic, philosophy Inverse deduction
Connectionists Neuroscience Back-Propagation
Evolutionary Evolutionary biology Evolutionary Algorithms
Bayesian Statistics Probabilistic inference
Analogizers Psychology Kernel machines
Formal Methods
How To Apply Search?
8
Problem reformulation:
• We need to reformulate SE (or ST) problems as optimization
problems
Define an objective function:
• Define a distance function that measure how far are we to
solve the SE (or ST) problem
Choose a solver:
• Genetic Algorithm, Random Search, Hill Climbing, etc.
1. Problem Reformulation
9
class Triangle {
int a, b, c; //sides
String type = "NOT_TRIANGLE";
Triangle (int a, int b, int c){…}
void computeTriangleType() {
1. if (a == b) {
2. if (b == c)
3. type = "EQUILATERAL";
else
4. type = "ISOSCELES";
} else {
5. if (a == c) {
6. type = "ISOSCELES";
} else {
7. if (b == c)
8. type = “ISOSCELES”;
else
9. type = “SCALENE”;
}
}
}
Class Under Test (CUT)
1
25
6 7 3
98
10
4
Control Flow Graph
1
5
7
9
10
Generate a test case that
covers all branches in the
selected path
2. Define an Objective Function
10
1
25
6 7 3
98
10
4
Control Flow Graph
1
5
7
9
10
Generate a test case that
covers all branches in the
selected path
Well-established heuristics:
- Approach level
- Branch distance
abs(a-b) + K
If (a==b)
Branch Distances
11
Rules for numeric data Rules for String data
B. Korel. IEEE TSE 1990 M. ALshbraideh et al. STVR 2006
3. Choose a Solver
12
Genetic Algorithms
13
In 1975 he wrote the
ground-breaking book on
genetic algorithms,
"Adaptation in Natural and
Artificial Systems"
John Henry Holland
P. Tonella, “Evolutionary
Testing of Classes”, ISSTA
2004
Genetic Algorithms
14
Test Case
Selection
Initial
Tests
Search
Test
Execution
Variants
Generation
Test Case
@Test
public void test(){
Triangle t = new Triangle(1,2,3);
String type = t.computeType();
assertEqual(type, ‘SCALENE’);
}
@Test
public void test(){
// Constructor (init)
// Method Calls
// Assertions (check)
}
Template
Genetic Algorithms
15
Test Case
Selection
Initial
Tests
Search
Test
Execution
Variants
Generation
Test cases are selected
according to their 'fitness'
Fitness is measured using
approach level and branch
distances for a given
(target) branch
16
Test Case
Selection
Initial
Tests
Search
Test
Execution
Variants
Generation
Parent 1
@Test
public void test(){
Triangle t = new Triangle(1,2,3);
String type = t.computeType();
assertEqual(type, ‘SCALENE’);
}
Parent 2
@Test
public void test(){
Triangle t = new Triangle(3,2,1);
boolean flag = t.isTriangle();
assertTrue(flag);
}
Single-Point Crossover
Genetic Algorithms
17
Test Case
Selection
Initial
Tests
Search
Test
Execution
Variants
Generation
Parent 1
@Test
public void test(){
Triangle t = new Triangle(1,2,3);
boolean flag = t.isTriangle();
assertTrue(flag);
}
Parent 2
@Test
public void test(){
Triangle t = new Triangle(3,2,1);
String type = t.computeType();
assertEqual(type, ‘SCALENE’);
}
Single-Point Crossover
Genetic Algorithms
18
Test Case
Selection
Initial
Tests
Search
Test
Execution
Variants
Generation
Offspring 1
@Test
public void test(){
Triangle t = new Triangle(1,2,3);
boolean flag = t.isRightAngle();
assertTrue(flag); //assertion updated
}
Offspring 2
@Test
public void test(){
Triangle t = new Triangle(3,5,1);
String type = t.computeType();
assertEqual(type, ‘SCALENE’);
Single-Point Crossover
Uniform Mutation
Genetic Algorithms
19
Too Many Paths?
1
25
6 7 3
98
10
4
Control Flow Graph
Even small program have multiple paths:
<1, 2, 4, 10>
<1, 2, 3, 10>
<1, 5, 7, 9, 10>
<1, 5, 6, 10>
Obj. Function 1
Obj. Function 2
Obj. Function 3
Obj. Function 4
How can we solve multiple-paths
(many-functions) in the same time?
How to Solve Multiple
Targets?
20
21
Single Target Approach
1
25
6 7 3
98
10
4
Control Flow Graph TestSuite = {}
For each uncovered target {
[Fit,Test] = GeneticAlgorithm(target)
If (Fit == 0)
TestSuite = TestSuite + Test
}
return(TestSuite)
Limitations:
1) In which order should we select the targets?
2) Some targets are more difficult than other
(how to split the time?)
3) Infeasible paths?
22
Linear Independent Path-Based Search (LIPS)
Key Ingredients:
1) Use the tests from previous GA runs as
starting test for the next GA runs
2) Select the last branches in independent
paths as targets
3) Dynamic budget re-allocation
1
25
6 7 3
98
10
4
Scalabrino et al. SSBSE 2016
Targets to
optimize first
23
Many-Objective Sorting Algorithms (MOSA)
b1 = |a-0|
Example:
b2 = |a-1|
b3 = |a+1|
example(2)
example(0)
example(-2)
Given: B = {b1, . . . , bm} branches of a program.
Find: test cases T = {t1, . . . , tn} minimising the following fitness objectives:
min f1(T) = approach_level(b1) + branch_distance(b1)
min f2(T) = approach_level(b2) + branch_distance(b2)
…
min fm(T) = approach_level(bm) + branch_distance(bm)
String example(int a) {
switch (a) {
case 0 : return “0”;
case 1 : return “1”;
case -1 : return “-1”;
default: return “default”;
}
24
Many-Objective Sorting Algorithms (MOSA)
Objective 1
Objective 2
Not all non-dominated
solutions are optimal for
the purpose of testing
Min
Min
[A. Panichella, F. Kifetew,
P. Tonella ICST 2015]
Pareto
Front
These points are
better than others
25
DynaMOSA: Dynamic MOSA
1
25
6 7 3
98
10
4
Control Flow Graph
Rationale:
• Not all branches (objectives) are
independent from one another
• We cannot cover branch <3,10> without
covering <2,3>
Idea:
• Organize targets in levels based on their
structural dependencies
• Start the search with the first-level
targets, then optimize the second level,
and so on
1* Level
2* Level
3* Level
[A. Panichella, F. Kifetew,
P. Tonella, TSE 2018]
26
Many Independent Objective (MIO)
MIO is a co-evolutionary algorithms:
• Different Islands/populations
• One Island for each target
• Test cases within the same island are
ranked exclusively according to the
function for the corresponding target
• Islands associated to probably
infeasible targets are ignored during the
evolution
1
25
6 7 3
98
10
4
<1,5> <1,2>
<5,6>
…
Island
Test Case
Target
27
Whole-Suite Approach (WSA)
A solution is a test suite rather than a test
cases (different granularity level)
Test Suite
Test Case
Fitness Function = Sum of all branch
distances
Crossover = Switching test cases between
two test suites
Mutation = add, remove, edit a test case
28
Previous Study Claims
Scalabrino et al.
SSBSE 2016
Roja et al.
EMSE 2017
Panichella et al.
ICST 2015
Panichella et al.
TSE 2018
Arcuri
SSBSE 2017
LIPS more
efficient than
MOSA
Whole-suite
better than
single-target
MOSA is better
than Whole-
suite
DynaMOSA is
better than
MOSA
MIO is as
competitive to
MOSA
Need forLarge-scale
Comparison
29
30
http://www.evosuite.org • Command Line
• Eclipse Plugin
• Intellij IDEA plugin
• Maven Plugin
• Measure Code Coverage
31
https://github.com/EvoSuite/evosuite
• Single Target (ST)
• Whole-Suite Approach (WSA)
• MOSA
• DynaMOSA
• MIO
• LIPS
Our
Implementation
Benchmark
32
Benchmark:
175 non-trivial classes sampled from SF110
+ 5 largest classes in SF110
Selection Procedure:
• Computing the McCabe’s cyclomatic complexity (MCC)
• Filtering out all trivial classes (having only methods with MCC <5)
• Random sampling from the pruned projects
Search Budget: Three minutes
RQ1: How Do the Different Algorithms
Perform in Terms of Code Coverage?
33
# Classes
No Winner
DynaMOSA
MOSA
MIO
WS
Single
LIPS
0 17,5 35 52,5 70
Pairwise Comparison
34
Vs. DynaMOSA LIPS MIO MOSA ST WS
DynaMOSA - 122 79 41 177 76
LIPS 2 - 17 11 175 14
MIO 12 87 - 19 175 40
MOSA 6 105 74 - 175 59
ST 0 0 0 1 - 0
WS 11 103 53 22 174
#Classes in which an algorithm A (row) outperforms another
algorithm B (column) according to the Wilcoxon test
DynaMOSA
outperforms
other algorithms
in a large number
of cases
ST and LIPS
are the least
performant
Friedman’s Test
35
ID Meta-heuristics Ranking Statistically better than
(1) DynaMOSA 2.05 2, 3, 4, 5, 6
(2) MOSA 2.63 3, 4, 5, 6
(3) WSA 3.10 4, 5, 6
(4) MIO 3.24 5, 6
(5) LIPS 4.10 6
(6) ST 5.87 -
Results of the Friedman test
(p-value = 3.79 x 10-10)
RQ2: How Do the Different Algorithms
Perform Over Time?
36
Coverage
Time
Algorithm 1
Algorithm 2
The final coverage tells only
part of the story
Two algorithm may perform
differently over time even if
they reach the same final
coverage
Let’s use the Area Under the
Chart (AUC) as metric
37
# Classes
No Winner
DynaMOSA
MOSA
MIO
WS
Single
LIPS
0 30 60 90 120
RQ2: How Do the Different Algorithms
Perform Over Time?
Friedman’s Test
38
ID Meta-heuristics Ranking Statistically better than
(1) DynaMOSA 1.71 2, 3, 4, 5, 6
(2) MOSA 2.46 3, 4, 5, 6
(3) WSA 2.77 4, 5, 6
(4) MIO 3.99 5, 6
(5) LIPS 4.21 6
(6) ST 5.85 -
Results of the Friedman test
(p-value = 1.14 x 10-12)
RQ3: Does the Class Size Affect the
Performance of the Different Algorithms?
39
Rank Approach Statistically better than
(1) 1.71 DynaMOSA (2), (3), (4), (5), (6)
(2) 2.46 MOSA (3), (4), (5), (6)
(3) 2.77 MIO (4), (5), (6)
(4) 3.99 WSA (5), (6)
(5) 4.21 LIPS (6)
(6) 5.85 ST -
DynaMOSA
MOSA
MIO
WSA
LIPS
ST
27
32
47
67
82
125
190
353
7938
#Branch
0.00
0.20
0.40
0.60
0.80
1.00
BranchCoverage
Figure 5: Heatmap showing the interaction between branch coverage a
40
Previous Study Claims
Scalabrino et al.
SSBSE 2016
Roja et al.
EMSE 2017
Panichella et al.
ICST 2015
Panichella et al.
TSE 2018
Arcuri
SSBSE 2017
LIPS more
efficient than
MOSA
Whole-suite
better than
single-target
MOSA is better
than Whole-
suite
DynaMOSA is
better than
MOSA
MIO is as
competitive to
MOSA
Approved Approved ApprovedApproved
Not
Approved
Demo
41
42
More Studies
A. Panichella, F. Kifetew, P. Tonella (IST 2018) J. Campos et al. (IST 2018)
Confirm our Results
AI-Based Testing at TUDelft
43
https://github.com/STAMP-project/botsing https://github.com/SERG-Delft/evosql
https://github.com/apanichella/evosuite https://github.com/dappelt/xavier-grammar
Testing Selft-Driving Cars
44
Automated Test Generation for
Unit Testing and Beyond
Annibale Panichella
a.panichella@tudelf.nl
@AnniPanic
45
1 of 45

Recommended

Automated Repair of Feature Interaction Failures in Automated Driving Systems by
Automated Repair of Feature Interaction Failures in Automated Driving SystemsAutomated Repair of Feature Interaction Failures in Automated Driving Systems
Automated Repair of Feature Interaction Failures in Automated Driving SystemsLionel Briand
609 views20 slides
Log-Based Slicing for System-Level Test Cases by
Log-Based Slicing for System-Level Test CasesLog-Based Slicing for System-Level Test Cases
Log-Based Slicing for System-Level Test CasesLionel Briand
471 views19 slides
Automated Vulnerability Testing Using Machine Learning and Metaheuristic Search by
Automated Vulnerability Testing Using Machine Learning and Metaheuristic SearchAutomated Vulnerability Testing Using Machine Learning and Metaheuristic Search
Automated Vulnerability Testing Using Machine Learning and Metaheuristic SearchLionel Briand
1.2K views45 slides
Log-Based Slicing for System-Level Test Cases (ISSTA 2021) by
Log-Based Slicing for System-Level Test Cases (ISSTA 2021)Log-Based Slicing for System-Level Test Cases (ISSTA 2021)
Log-Based Slicing for System-Level Test Cases (ISSTA 2021)Donghwan Shin
92 views19 slides
Trace-Checking CPS Properties: Bridging the Cyber-Physical Gap by
Trace-Checking CPS Properties: Bridging the Cyber-Physical GapTrace-Checking CPS Properties: Bridging the Cyber-Physical Gap
Trace-Checking CPS Properties: Bridging the Cyber-Physical GapLionel Briand
260 views38 slides
Griffin: Grouping Suspicious Memory-Access Patterns to Improve Understanding... by
Griffin: Grouping Suspicious Memory-Access Patterns to Improve Understanding...Griffin: Grouping Suspicious Memory-Access Patterns to Improve Understanding...
Griffin: Grouping Suspicious Memory-Access Patterns to Improve Understanding...Sangmin Park
412 views45 slides

More Related Content

What's hot

Search-driven String Constraint Solving for Vulnerability Detection by
Search-driven String Constraint Solving for Vulnerability DetectionSearch-driven String Constraint Solving for Vulnerability Detection
Search-driven String Constraint Solving for Vulnerability DetectionLionel Briand
345 views35 slides
Session 6 sv_randomization by
Session 6 sv_randomizationSession 6 sv_randomization
Session 6 sv_randomizationNirav Desai
6.3K views58 slides
C++ Unit Test with Google Testing Framework by
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkHumberto Marchezi
7.4K views52 slides
Test driven development by
Test driven developmentTest driven development
Test driven developmentchristoforosnalmpantis
786 views27 slides
Testing with Junit4 by
Testing with Junit4Testing with Junit4
Testing with Junit4Amila Paranawithana
1.6K views28 slides
Scientific Software Development by
Scientific Software DevelopmentScientific Software Development
Scientific Software Developmentjalle6
611 views41 slides

What's hot(20)

Search-driven String Constraint Solving for Vulnerability Detection by Lionel Briand
Search-driven String Constraint Solving for Vulnerability DetectionSearch-driven String Constraint Solving for Vulnerability Detection
Search-driven String Constraint Solving for Vulnerability Detection
Lionel Briand345 views
Session 6 sv_randomization by Nirav Desai
Session 6 sv_randomizationSession 6 sv_randomization
Session 6 sv_randomization
Nirav Desai6.3K views
C++ Unit Test with Google Testing Framework by Humberto Marchezi
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing Framework
Humberto Marchezi7.4K views
Scientific Software Development by jalle6
Scientific Software DevelopmentScientific Software Development
Scientific Software Development
jalle6611 views
TMPA-2017: 5W+1H Static Analysis Report Quality Measure by Iosif Itkin
TMPA-2017: 5W+1H Static Analysis Report Quality MeasureTMPA-2017: 5W+1H Static Analysis Report Quality Measure
TMPA-2017: 5W+1H Static Analysis Report Quality Measure
Iosif Itkin1.1K views
xUnit Style Database Testing by Chris Oldwood
xUnit Style Database TestingxUnit Style Database Testing
xUnit Style Database Testing
Chris Oldwood1.6K views
SERENE 2014 Workshop: Paper "Using Instrumentation for Quality Assessment of ... by SERENEWorkshop
SERENE 2014 Workshop: Paper "Using Instrumentation for Quality Assessment of ...SERENE 2014 Workshop: Paper "Using Instrumentation for Quality Assessment of ...
SERENE 2014 Workshop: Paper "Using Instrumentation for Quality Assessment of ...
SERENEWorkshop526 views
Concurrency: Mutual Exclusion and Synchronization by Anas Ebrahim
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
Anas Ebrahim6.1K views
Process Synchronization And Deadlocks by tech2click
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
tech2click13.5K views
Known XML Vulnerabilities Are Still a Threat to Popular Parsers ! & Open Sour... by Lionel Briand
Known XML Vulnerabilities Are Still a Threat to Popular Parsers ! & Open Sour...Known XML Vulnerabilities Are Still a Threat to Popular Parsers ! & Open Sour...
Known XML Vulnerabilities Are Still a Threat to Popular Parsers ! & Open Sour...
Lionel Briand2.1K views
Operating Systems - Process Synchronization and Deadlocks by Mukesh Chinta
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
Mukesh Chinta6.3K views
System Test Evaluation and Review Technique by Aniket Mitra
System Test Evaluation and Review TechniqueSystem Test Evaluation and Review Technique
System Test Evaluation and Review Technique
Aniket Mitra743 views
TMPA-2017: Distributed Analysis of the BMC Kind: Making It Fit the Tornado Su... by Iosif Itkin
TMPA-2017: Distributed Analysis of the BMC Kind: Making It Fit the Tornado Su...TMPA-2017: Distributed Analysis of the BMC Kind: Making It Fit the Tornado Su...
TMPA-2017: Distributed Analysis of the BMC Kind: Making It Fit the Tornado Su...
Iosif Itkin793 views
Implementation of Election Algorithm of Distributed Systems in Client-Server ... by Mushfekur Rahman
Implementation of Election Algorithm of Distributed Systems in Client-Server ...Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Mushfekur Rahman184 views

Similar to IPA Fall Days 2019

Simple rules for building robust machine learning models by
Simple rules for building robust machine learning modelsSimple rules for building robust machine learning models
Simple rules for building robust machine learning modelsKyriakos Chatzidimitriou
106 views77 slides
Sbst2018 contest2018 by
Sbst2018 contest2018Sbst2018 contest2018
Sbst2018 contest2018Annibale Panichella
125 views24 slides
White Box testing by Pankaj Thakur, NITTTR Chandigarh by
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhPankaj Thakur
460 views34 slides
Software Quality Testing by
Software Quality TestingSoftware Quality Testing
Software Quality TestingKiran Kumar
2.7K views29 slides
Monte Carlo Simulation for project estimates v1.0 by
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0PMILebanonChapter
6.9K views65 slides
Functional Operations - Susan Potter by
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potterdistributed matters
912 views76 slides

Similar to IPA Fall Days 2019(20)

White Box testing by Pankaj Thakur, NITTTR Chandigarh by Pankaj Thakur
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
Pankaj Thakur460 views
Software Quality Testing by Kiran Kumar
Software Quality TestingSoftware Quality Testing
Software Quality Testing
Kiran Kumar2.7K views
Monte Carlo Simulation for project estimates v1.0 by PMILebanonChapter
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0
PMILebanonChapter6.9K views
Shift-Left Testing: QA in a DevOps World by David Laulusa by QA or the Highway
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
QA or the Highway257 views
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr... by PyData
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
PyData8.8K views
Multimodal Residual Learning for Visual Question-Answering by NAVER D2
Multimodal Residual Learning for Visual Question-AnsweringMultimodal Residual Learning for Visual Question-Answering
Multimodal Residual Learning for Visual Question-Answering
NAVER D21.3K views
SBST 2015 - 3rd Tool Competition for Java Junit test Tools by Tanja Vos
SBST 2015 - 3rd Tool Competition for Java Junit test ToolsSBST 2015 - 3rd Tool Competition for Java Junit test Tools
SBST 2015 - 3rd Tool Competition for Java Junit test Tools
Tanja Vos1K views
Nighthawk: A Two-Level Genetic-Random Unit Test Data Generator by CS, NcState
Nighthawk: A Two-Level Genetic-Random Unit Test Data GeneratorNighthawk: A Two-Level Genetic-Random Unit Test Data Generator
Nighthawk: A Two-Level Genetic-Random Unit Test Data Generator
CS, NcState1K views
Cs141 mid termexam v1 by Fahadaio
Cs141 mid termexam v1Cs141 mid termexam v1
Cs141 mid termexam v1
Fahadaio15 views
2016 10-04: tdd++: tdd made easier by Christian Hujer
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
Christian Hujer394 views
USING CUCKOO ALGORITHM FOR ESTIMATING TWO GLSD PARAMETERS AND COMPARING IT WI... by ijcsit
USING CUCKOO ALGORITHM FOR ESTIMATING TWO GLSD PARAMETERS AND COMPARING IT WI...USING CUCKOO ALGORITHM FOR ESTIMATING TWO GLSD PARAMETERS AND COMPARING IT WI...
USING CUCKOO ALGORITHM FOR ESTIMATING TWO GLSD PARAMETERS AND COMPARING IT WI...
ijcsit46 views

More from Annibale Panichella

Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar... by
Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar...Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar...
Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar...Annibale Panichella
2 views21 slides
A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica... by
A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica...A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica...
A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica...Annibale Panichella
2 views27 slides
An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op... by
An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op...An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op...
An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op...Annibale Panichella
44 views24 slides
VST2022.pdf by
VST2022.pdfVST2022.pdf
VST2022.pdfAnnibale Panichella
137 views77 slides
An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O... by
An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O...An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O...
An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O...Annibale Panichella
312 views27 slides
Speeding-up Software Testing With Computational Intelligence by
Speeding-up Software Testing With Computational IntelligenceSpeeding-up Software Testing With Computational Intelligence
Speeding-up Software Testing With Computational IntelligenceAnnibale Panichella
269 views29 slides

More from Annibale Panichella(19)

Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar... by Annibale Panichella
Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar...Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar...
Searching for Quality: Genetic Algorithms and Metamorphic Testing for Softwar...
A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica... by Annibale Panichella
A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica...A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica...
A Fast Multi-objective Evolutionary Approach for Designing Large-Scale Optica...
An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op... by Annibale Panichella
An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op...An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op...
An Improved Pareto Front Modeling Algorithm for Large-scale Many-Objective Op...
An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O... by Annibale Panichella
An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O...An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O...
An Adaptive Evolutionary Algorithm based on Non-Euclidean Geometry for Many-O...
Speeding-up Software Testing With Computational Intelligence by Annibale Panichella
Speeding-up Software Testing With Computational IntelligenceSpeeding-up Software Testing With Computational Intelligence
Speeding-up Software Testing With Computational Intelligence
Incremental Control Dependency Frontier Exploration for Many-Criteria Test C... by Annibale Panichella
Incremental Control Dependency Frontier Exploration for Many-Criteria  Test C...Incremental Control Dependency Frontier Exploration for Many-Criteria  Test C...
Incremental Control Dependency Frontier Exploration for Many-Criteria Test C...
Java Unit Testing Tool Competition — Fifth Round by Annibale Panichella
Java Unit Testing Tool Competition — Fifth RoundJava Unit Testing Tool Competition — Fifth Round
Java Unit Testing Tool Competition — Fifth Round
Parameterizing and Assembling IR-based Solutions for SE Tasks using Genetic A... by Annibale Panichella
Parameterizing and Assembling IR-based Solutions for SE Tasks using Genetic A...Parameterizing and Assembling IR-based Solutions for SE Tasks using Genetic A...
Parameterizing and Assembling IR-based Solutions for SE Tasks using Genetic A...
Reformulating Branch Coverage as a Many-Objective Optimization Problem by Annibale Panichella
Reformulating Branch Coverage as a Many-Objective Optimization ProblemReformulating Branch Coverage as a Many-Objective Optimization Problem
Reformulating Branch Coverage as a Many-Objective Optimization Problem
Results for EvoSuite-MOSA at the Third Unit Testing Tool Competition by Annibale Panichella
Results for EvoSuite-MOSA at the Third Unit Testing Tool CompetitionResults for EvoSuite-MOSA at the Third Unit Testing Tool Competition
Results for EvoSuite-MOSA at the Third Unit Testing Tool Competition
Adaptive User Feedback for IR-based Traceability Recovery by Annibale Panichella
Adaptive User Feedback for IR-based Traceability RecoveryAdaptive User Feedback for IR-based Traceability Recovery
Adaptive User Feedback for IR-based Traceability Recovery
Diversity mechanisms for evolutionary populations in Search-Based Software En... by Annibale Panichella
Diversity mechanisms for evolutionary populations in Search-Based Software En...Diversity mechanisms for evolutionary populations in Search-Based Software En...
Diversity mechanisms for evolutionary populations in Search-Based Software En...
Estimating the Evolution Direction of Populations to Improve Genetic Algorithms by Annibale Panichella
Estimating the Evolution Direction of Populations to Improve Genetic AlgorithmsEstimating the Evolution Direction of Populations to Improve Genetic Algorithms
Estimating the Evolution Direction of Populations to Improve Genetic Algorithms
When and How Using Structural Information to Improve IR-Based Traceability Re... by Annibale Panichella
When and How Using Structural Information to Improve IR-Based Traceability Re...When and How Using Structural Information to Improve IR-Based Traceability Re...
When and How Using Structural Information to Improve IR-Based Traceability Re...

Recently uploaded

What is API by
What is APIWhat is API
What is APIartembondar5
12 views15 slides
Benefits in Software Development by
Benefits in Software DevelopmentBenefits in Software Development
Benefits in Software DevelopmentJohn Valentino
5 views15 slides
The Era of Large Language Models.pptx by
The Era of Large Language Models.pptxThe Era of Large Language Models.pptx
The Era of Large Language Models.pptxAbdulVahedShaik
7 views9 slides
Top-5-production-devconMunich-2023.pptx by
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptxTier1 app
9 views40 slides
Dapr Unleashed: Accelerating Microservice Development by
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice DevelopmentMiroslav Janeski
13 views29 slides
Fleet Management Software in India by
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India Fleetable
12 views1 slide

Recently uploaded(20)

Top-5-production-devconMunich-2023.pptx by Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app9 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski13 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable12 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta9 views
FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan6 views
Sprint 226 by ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ11 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm15 views
Understanding HTML terminology by artembondar5
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminology
artembondar57 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492162 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin96 views

IPA Fall Days 2019

  • 1. Automated Test Generation for Unit Testing and Beyond Annibale Panichella a.panichella@tudelf.nl @AnniPanic 1
  • 2. Unit Testing 2 class Triangle { int a, b, c; //sides String type = "NOT_TRIANGLE"; Triangle (int a, int b, int c){…} void computeTriangleType() { 1. if (a == b) { 2. if (b == c) 3. type = "EQUILATERAL"; else 4. type = "ISOSCELES"; } else { 5. if (a == c) { 6. type = "ISOSCELES"; } else { 7. if (b == c) 8. type = “ISOSCELES”; else 9. type = “SCALENE”; } } } Class Under Test (CUT) @Test public void test(){ // Constructor (init) // Method Calls // Assertions (check) } Test Case @Test public void test(){ Triangle t = new Triangle (1,2,3); t.computeTriangleType(); String type = t.getType(); assertTrue(type.equals(“SCALENE”)); }
  • 3. 3 Is it that Easy? Class = Pass2Verifier.java Project = Apache commons BCEL
  • 4. How to Generate Tests in Reasonable Time? 4
  • 7. Artificial Intelligence? 7 [Domingos2015 “The Master Algorithm”] Neural Network Regression Support Vector Tribe Origin Master Algorithm Symbolists Logic, philosophy Inverse deduction Connectionists Neuroscience Back-Propagation Evolutionary Evolutionary biology Evolutionary Algorithms Bayesian Statistics Probabilistic inference Analogizers Psychology Kernel machines Formal Methods
  • 8. How To Apply Search? 8 Problem reformulation: • We need to reformulate SE (or ST) problems as optimization problems Define an objective function: • Define a distance function that measure how far are we to solve the SE (or ST) problem Choose a solver: • Genetic Algorithm, Random Search, Hill Climbing, etc.
  • 9. 1. Problem Reformulation 9 class Triangle { int a, b, c; //sides String type = "NOT_TRIANGLE"; Triangle (int a, int b, int c){…} void computeTriangleType() { 1. if (a == b) { 2. if (b == c) 3. type = "EQUILATERAL"; else 4. type = "ISOSCELES"; } else { 5. if (a == c) { 6. type = "ISOSCELES"; } else { 7. if (b == c) 8. type = “ISOSCELES”; else 9. type = “SCALENE”; } } } Class Under Test (CUT) 1 25 6 7 3 98 10 4 Control Flow Graph 1 5 7 9 10 Generate a test case that covers all branches in the selected path
  • 10. 2. Define an Objective Function 10 1 25 6 7 3 98 10 4 Control Flow Graph 1 5 7 9 10 Generate a test case that covers all branches in the selected path Well-established heuristics: - Approach level - Branch distance abs(a-b) + K If (a==b)
  • 11. Branch Distances 11 Rules for numeric data Rules for String data B. Korel. IEEE TSE 1990 M. ALshbraideh et al. STVR 2006
  • 12. 3. Choose a Solver 12
  • 13. Genetic Algorithms 13 In 1975 he wrote the ground-breaking book on genetic algorithms, "Adaptation in Natural and Artificial Systems" John Henry Holland P. Tonella, “Evolutionary Testing of Classes”, ISSTA 2004
  • 14. Genetic Algorithms 14 Test Case Selection Initial Tests Search Test Execution Variants Generation Test Case @Test public void test(){ Triangle t = new Triangle(1,2,3); String type = t.computeType(); assertEqual(type, ‘SCALENE’); } @Test public void test(){ // Constructor (init) // Method Calls // Assertions (check) } Template
  • 15. Genetic Algorithms 15 Test Case Selection Initial Tests Search Test Execution Variants Generation Test cases are selected according to their 'fitness' Fitness is measured using approach level and branch distances for a given (target) branch
  • 16. 16 Test Case Selection Initial Tests Search Test Execution Variants Generation Parent 1 @Test public void test(){ Triangle t = new Triangle(1,2,3); String type = t.computeType(); assertEqual(type, ‘SCALENE’); } Parent 2 @Test public void test(){ Triangle t = new Triangle(3,2,1); boolean flag = t.isTriangle(); assertTrue(flag); } Single-Point Crossover Genetic Algorithms
  • 17. 17 Test Case Selection Initial Tests Search Test Execution Variants Generation Parent 1 @Test public void test(){ Triangle t = new Triangle(1,2,3); boolean flag = t.isTriangle(); assertTrue(flag); } Parent 2 @Test public void test(){ Triangle t = new Triangle(3,2,1); String type = t.computeType(); assertEqual(type, ‘SCALENE’); } Single-Point Crossover Genetic Algorithms
  • 18. 18 Test Case Selection Initial Tests Search Test Execution Variants Generation Offspring 1 @Test public void test(){ Triangle t = new Triangle(1,2,3); boolean flag = t.isRightAngle(); assertTrue(flag); //assertion updated } Offspring 2 @Test public void test(){ Triangle t = new Triangle(3,5,1); String type = t.computeType(); assertEqual(type, ‘SCALENE’); Single-Point Crossover Uniform Mutation Genetic Algorithms
  • 19. 19 Too Many Paths? 1 25 6 7 3 98 10 4 Control Flow Graph Even small program have multiple paths: <1, 2, 4, 10> <1, 2, 3, 10> <1, 5, 7, 9, 10> <1, 5, 6, 10> Obj. Function 1 Obj. Function 2 Obj. Function 3 Obj. Function 4 How can we solve multiple-paths (many-functions) in the same time?
  • 20. How to Solve Multiple Targets? 20
  • 21. 21 Single Target Approach 1 25 6 7 3 98 10 4 Control Flow Graph TestSuite = {} For each uncovered target { [Fit,Test] = GeneticAlgorithm(target) If (Fit == 0) TestSuite = TestSuite + Test } return(TestSuite) Limitations: 1) In which order should we select the targets? 2) Some targets are more difficult than other (how to split the time?) 3) Infeasible paths?
  • 22. 22 Linear Independent Path-Based Search (LIPS) Key Ingredients: 1) Use the tests from previous GA runs as starting test for the next GA runs 2) Select the last branches in independent paths as targets 3) Dynamic budget re-allocation 1 25 6 7 3 98 10 4 Scalabrino et al. SSBSE 2016 Targets to optimize first
  • 23. 23 Many-Objective Sorting Algorithms (MOSA) b1 = |a-0| Example: b2 = |a-1| b3 = |a+1| example(2) example(0) example(-2) Given: B = {b1, . . . , bm} branches of a program. Find: test cases T = {t1, . . . , tn} minimising the following fitness objectives: min f1(T) = approach_level(b1) + branch_distance(b1) min f2(T) = approach_level(b2) + branch_distance(b2) … min fm(T) = approach_level(bm) + branch_distance(bm) String example(int a) { switch (a) { case 0 : return “0”; case 1 : return “1”; case -1 : return “-1”; default: return “default”; }
  • 24. 24 Many-Objective Sorting Algorithms (MOSA) Objective 1 Objective 2 Not all non-dominated solutions are optimal for the purpose of testing Min Min [A. Panichella, F. Kifetew, P. Tonella ICST 2015] Pareto Front These points are better than others
  • 25. 25 DynaMOSA: Dynamic MOSA 1 25 6 7 3 98 10 4 Control Flow Graph Rationale: • Not all branches (objectives) are independent from one another • We cannot cover branch <3,10> without covering <2,3> Idea: • Organize targets in levels based on their structural dependencies • Start the search with the first-level targets, then optimize the second level, and so on 1* Level 2* Level 3* Level [A. Panichella, F. Kifetew, P. Tonella, TSE 2018]
  • 26. 26 Many Independent Objective (MIO) MIO is a co-evolutionary algorithms: • Different Islands/populations • One Island for each target • Test cases within the same island are ranked exclusively according to the function for the corresponding target • Islands associated to probably infeasible targets are ignored during the evolution 1 25 6 7 3 98 10 4 <1,5> <1,2> <5,6> … Island Test Case Target
  • 27. 27 Whole-Suite Approach (WSA) A solution is a test suite rather than a test cases (different granularity level) Test Suite Test Case Fitness Function = Sum of all branch distances Crossover = Switching test cases between two test suites Mutation = add, remove, edit a test case
  • 28. 28 Previous Study Claims Scalabrino et al. SSBSE 2016 Roja et al. EMSE 2017 Panichella et al. ICST 2015 Panichella et al. TSE 2018 Arcuri SSBSE 2017 LIPS more efficient than MOSA Whole-suite better than single-target MOSA is better than Whole- suite DynaMOSA is better than MOSA MIO is as competitive to MOSA
  • 30. 30 http://www.evosuite.org • Command Line • Eclipse Plugin • Intellij IDEA plugin • Maven Plugin • Measure Code Coverage
  • 31. 31 https://github.com/EvoSuite/evosuite • Single Target (ST) • Whole-Suite Approach (WSA) • MOSA • DynaMOSA • MIO • LIPS Our Implementation
  • 32. Benchmark 32 Benchmark: 175 non-trivial classes sampled from SF110 + 5 largest classes in SF110 Selection Procedure: • Computing the McCabe’s cyclomatic complexity (MCC) • Filtering out all trivial classes (having only methods with MCC <5) • Random sampling from the pruned projects Search Budget: Three minutes
  • 33. RQ1: How Do the Different Algorithms Perform in Terms of Code Coverage? 33 # Classes No Winner DynaMOSA MOSA MIO WS Single LIPS 0 17,5 35 52,5 70
  • 34. Pairwise Comparison 34 Vs. DynaMOSA LIPS MIO MOSA ST WS DynaMOSA - 122 79 41 177 76 LIPS 2 - 17 11 175 14 MIO 12 87 - 19 175 40 MOSA 6 105 74 - 175 59 ST 0 0 0 1 - 0 WS 11 103 53 22 174 #Classes in which an algorithm A (row) outperforms another algorithm B (column) according to the Wilcoxon test DynaMOSA outperforms other algorithms in a large number of cases ST and LIPS are the least performant
  • 35. Friedman’s Test 35 ID Meta-heuristics Ranking Statistically better than (1) DynaMOSA 2.05 2, 3, 4, 5, 6 (2) MOSA 2.63 3, 4, 5, 6 (3) WSA 3.10 4, 5, 6 (4) MIO 3.24 5, 6 (5) LIPS 4.10 6 (6) ST 5.87 - Results of the Friedman test (p-value = 3.79 x 10-10)
  • 36. RQ2: How Do the Different Algorithms Perform Over Time? 36 Coverage Time Algorithm 1 Algorithm 2 The final coverage tells only part of the story Two algorithm may perform differently over time even if they reach the same final coverage Let’s use the Area Under the Chart (AUC) as metric
  • 37. 37 # Classes No Winner DynaMOSA MOSA MIO WS Single LIPS 0 30 60 90 120 RQ2: How Do the Different Algorithms Perform Over Time?
  • 38. Friedman’s Test 38 ID Meta-heuristics Ranking Statistically better than (1) DynaMOSA 1.71 2, 3, 4, 5, 6 (2) MOSA 2.46 3, 4, 5, 6 (3) WSA 2.77 4, 5, 6 (4) MIO 3.99 5, 6 (5) LIPS 4.21 6 (6) ST 5.85 - Results of the Friedman test (p-value = 1.14 x 10-12)
  • 39. RQ3: Does the Class Size Affect the Performance of the Different Algorithms? 39 Rank Approach Statistically better than (1) 1.71 DynaMOSA (2), (3), (4), (5), (6) (2) 2.46 MOSA (3), (4), (5), (6) (3) 2.77 MIO (4), (5), (6) (4) 3.99 WSA (5), (6) (5) 4.21 LIPS (6) (6) 5.85 ST - DynaMOSA MOSA MIO WSA LIPS ST 27 32 47 67 82 125 190 353 7938 #Branch 0.00 0.20 0.40 0.60 0.80 1.00 BranchCoverage Figure 5: Heatmap showing the interaction between branch coverage a
  • 40. 40 Previous Study Claims Scalabrino et al. SSBSE 2016 Roja et al. EMSE 2017 Panichella et al. ICST 2015 Panichella et al. TSE 2018 Arcuri SSBSE 2017 LIPS more efficient than MOSA Whole-suite better than single-target MOSA is better than Whole- suite DynaMOSA is better than MOSA MIO is as competitive to MOSA Approved Approved ApprovedApproved Not Approved
  • 42. 42 More Studies A. Panichella, F. Kifetew, P. Tonella (IST 2018) J. Campos et al. (IST 2018) Confirm our Results
  • 43. AI-Based Testing at TUDelft 43 https://github.com/STAMP-project/botsing https://github.com/SERG-Delft/evosql https://github.com/apanichella/evosuite https://github.com/dappelt/xavier-grammar
  • 45. Automated Test Generation for Unit Testing and Beyond Annibale Panichella a.panichella@tudelf.nl @AnniPanic 45