Creating Unit Tests Using Genetic Programming

E
ESUGESUG
Creating Unit Tests Using Genetic
Programming
Alexandre Bergel, Geraldine Galindo-Gutiérrez, Alison Fernandez-Blanco, Juan-Pablo Sandoval-Alcocer
🇨🇭RelationalAI
🇧🇴Universidad Católica Boliviana “San Pablo”
🇨🇱Ponti
fi
cia Universidad Católica de Chile
https://bergel.eu
Generating Unit Tests
Contribute to making a software more reliable
Ef
fi
cient at identifying bugs
Used in prominent software companies
Complement hand written tests
Many techniques: fuzzingbook.org
In a Nutshell
+
Genetic Algorithm
Selection based
on speed
Reproduction
Remplacement
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
{—— -
- —-
- -—
—-
—— -}
Genetic Algorithm applied to tests
Selection based
on coverage
Combination
Remplacement
Test as a chromosome
{—— -
- —-
- -—
—-
—— -}
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := GCPoint new.
v6 := v1 y.
v7 := v3 negated.
v8 := v5 add: v3.
Test as a chromosome
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := GCPoint new.
v6 := v1 y.
v7 := v3 negated.
v8 := v5 add: v3.
The Genetic Algorithm
searches for the optimal
sequence of instructions to
maximize the test
coverage.
Test as a chromosome
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := GCPoint new.
v6 := v1 y.
v7 := v3 negated.
v8 := v5 add: v3.
Two kinds of statements:
- object construction
- message send
Test as a chromosome
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := GCPoint new.
v6 := v1 y.
v7 := v3 negated.
v8 := v5 add: v3.
Require a code example to extract
argument type information.
This is how correct arguments can be
provided to message statements.
Test as a chromosome
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := GCPoint new.
v6 := v1 y.
v7 := v3 negated.
v8 := v5 add: v3.
Some statements have requirements.
A number is necessary to invoke x:y:
Example of a mutation
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := GCPoint new 5.
v6 := v1 y.
v7 := v3 negated.
v8 := v5 add: v3.
The construction of a point is
replaced by a construction of a
number.
Variable adjustment
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := GCPoint new 5.
v6 := v1 y.
v7 := v3 negated.
v8 := v5 add: v3.
v1 := GCPoint new.
v2 := 4.
v3 := v1 x: v2 y: v2.
v4 := v3 negated.
v5 := 5.
v6 := v1 y.
v7 := v3 negated.
v8 := v3 add: v3.
Future work
Improvement of the test generation
Be smarter to explore new code paths
Compare SmallEvoTest with Pingüin for Python
Visualize the evolution of tests
Creating Unit Tests Using Genetic Programming
Preliminary conclusion
Pro
fi
ling an example to infer parameter types seems to give good results
Base for future researches and experiments
Available under the MIT License, for Pharo and GToolkit
🤗
1 von 16

Recomendados

MT_01_unittest_python.pdf von
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdfHans Jones
16 views26 Folien
Rechecking SharpDevelop: Any New Bugs? von
Rechecking SharpDevelop: Any New Bugs?Rechecking SharpDevelop: Any New Bugs?
Rechecking SharpDevelop: Any New Bugs?PVS-Studio
71 views9 Folien
Altitude San Francisco 2018: Testing with Fastly Workshop von
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopFastly
181 views66 Folien
Errors detected in C++Builder von
Errors detected in C++BuilderErrors detected in C++Builder
Errors detected in C++BuilderPVS-Studio
334 views7 Folien
Long-Awaited Check of CryEngine V von
Long-Awaited Check of CryEngine VLong-Awaited Check of CryEngine V
Long-Awaited Check of CryEngine VPVS-Studio
80 views25 Folien
An Introduction to Property Based Testing von
An Introduction to Property Based TestingAn Introduction to Property Based Testing
An Introduction to Property Based TestingC4Media
497 views93 Folien

Más contenido relacionado

Similar a Creating Unit Tests Using Genetic Programming

Leveling Up With Unit Testing - php[tek] 2023 von
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
48 views75 Folien
Source code of WPF samples by Microsoft was checked von
Source code of WPF samples by Microsoft was checkedSource code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checkedPVS-Studio
71 views16 Folien
yelp data challenge von
yelp data challengeyelp data challenge
yelp data challengeAMR koura
626 views30 Folien
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin... von
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin...A Practical Approach to Building a Streaming Processing Pipeline for an Onlin...
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin...Databricks
1K views57 Folien
Analyzing ReactOS One More Time von
Analyzing ReactOS One More TimeAnalyzing ReactOS One More Time
Analyzing ReactOS One More TimePVS-Studio
97 views12 Folien
Designing process flows with #Baker von
Designing process flows with #BakerDesigning process flows with #Baker
Designing process flows with #BakerBekir Oguz
1.4K views79 Folien

Similar a Creating Unit Tests Using Genetic Programming(20)

Leveling Up With Unit Testing - php[tek] 2023 von Mark Niebergall
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
Mark Niebergall48 views
Source code of WPF samples by Microsoft was checked von PVS-Studio
Source code of WPF samples by Microsoft was checkedSource code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checked
PVS-Studio71 views
yelp data challenge von AMR koura
yelp data challengeyelp data challenge
yelp data challenge
AMR koura626 views
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin... von Databricks
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin...A Practical Approach to Building a Streaming Processing Pipeline for an Onlin...
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin...
Databricks1K views
Analyzing ReactOS One More Time von PVS-Studio
Analyzing ReactOS One More TimeAnalyzing ReactOS One More Time
Analyzing ReactOS One More Time
PVS-Studio97 views
Designing process flows with #Baker von Bekir Oguz
Designing process flows with #BakerDesigning process flows with #Baker
Designing process flows with #Baker
Bekir Oguz1.4K views
Neal Gafter Java Evolution von deimos
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolution
deimos784 views
Critical errors in CryEngine V code von PVS-Studio
Critical errors in CryEngine V codeCritical errors in CryEngine V code
Critical errors in CryEngine V code
PVS-Studio24 views
Java Unit Testing Tool Competition — Fifth Round von Annibale Panichella
Java Unit Testing Tool Competition — Fifth RoundJava Unit Testing Tool Competition — Fifth Round
Java Unit Testing Tool Competition — Fifth Round
Leveling Up With Unit Testing - LonghornPHP 2022 von Mark Niebergall
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
Mark Niebergall35 views
Linux version of PVS-Studio couldn't help checking CodeLite von PVS-Studio
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLite
PVS-Studio39 views
Windmill Testing certification von Vskills
Windmill Testing certificationWindmill Testing certification
Windmill Testing certification
Vskills430 views
APIs and Synthetic Biology von Uri Laserson
APIs and Synthetic BiologyAPIs and Synthetic Biology
APIs and Synthetic Biology
Uri Laserson2.8K views
Md university cmis 102 week 4 hands on lab new von eyavagal
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
eyavagal9 views
Deep Parameters Tuning for Android Mobile Apps von Davide De Chiara
Deep Parameters Tuning for Android Mobile AppsDeep Parameters Tuning for Android Mobile Apps
Deep Parameters Tuning for Android Mobile Apps
Davide De Chiara277 views
Scikit-Learn: Machine Learning in Python von Microsoft
Scikit-Learn: Machine Learning in PythonScikit-Learn: Machine Learning in Python
Scikit-Learn: Machine Learning in Python
Microsoft4.5K views

Más de ESUG

Workshop: Identifying concept inventories in agile programming von
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
12 views16 Folien
Technical documentation support in Pharo von
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
31 views39 Folien
The Pharo Debugger and Debugging tools: Advances and Roadmap von
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
56 views44 Folien
Sequence: Pipeline modelling in Pharo von
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
86 views22 Folien
Migration process from monolithic to micro frontend architecture in mobile ap... von
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
23 views35 Folien
Analyzing Dart Language with Pharo: Report and early results von
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
107 views30 Folien

Más de ESUG(20)

Workshop: Identifying concept inventories in agile programming von ESUG
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
ESUG12 views
Technical documentation support in Pharo von ESUG
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
ESUG31 views
The Pharo Debugger and Debugging tools: Advances and Roadmap von ESUG
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
ESUG56 views
Sequence: Pipeline modelling in Pharo von ESUG
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
ESUG86 views
Migration process from monolithic to micro frontend architecture in mobile ap... von ESUG
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
ESUG23 views
Analyzing Dart Language with Pharo: Report and early results von ESUG
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
ESUG107 views
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6 von ESUG
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
ESUG38 views
A Unit Test Metamodel for Test Generation von ESUG
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
ESUG53 views
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes von ESUG
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
ESUG52 views
Exploring GitHub Actions through EGAD: An Experience Report von ESUG
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
ESUG17 views
Pharo: a reflective language A first systematic analysis of reflective APIs von ESUG
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
ESUG57 views
Garbage Collector Tuning von ESUG
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
ESUG20 views
Improving Performance Through Object Lifetime Profiling: the DataFrame Case von ESUG
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
ESUG43 views
Pharo DataFrame: Past, Present, and Future von ESUG
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG43 views
thisContext in the Debugger von ESUG
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
ESUG36 views
Websockets for Fencing Score von ESUG
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
ESUG18 views
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript von ESUG
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ESUG46 views
Advanced Object- Oriented Design Mooc von ESUG
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
ESUG85 views
A New Architecture Reconciling Refactorings and Transformations von ESUG
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
ESUG28 views
BioSmalltalk von ESUG
BioSmalltalkBioSmalltalk
BioSmalltalk
ESUG415 views

Último

Understanding HTML terminology von
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminologyartembondar5
6 views8 Folien
Introduction to Gradle von
Introduction to GradleIntroduction to Gradle
Introduction to GradleJohn Valentino
5 views7 Folien
AI and Ml presentation .pptx von
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptxFayazAli87
13 views15 Folien
Keep von
KeepKeep
KeepGeniusee
78 views10 Folien
JioEngage_Presentation.pptx von
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptxadmin125455
6 views4 Folien
Introduction to Git Source Control von
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source ControlJohn Valentino
6 views18 Folien

Último(20)

Understanding HTML terminology von artembondar5
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminology
artembondar56 views
AI and Ml presentation .pptx von FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8713 views
JioEngage_Presentation.pptx von admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254556 views
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation von HCLSoftware
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook AutomationDRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation
HCLSoftware6 views
Generic or specific? Making sensible software design decisions von Bert Jan Schrijver
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Airline Booking Software von SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta7 views
Copilot Prompting Toolkit_All Resources.pdf von Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana16 views
360 graden fabriek von info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492143 views
Software evolution understanding: Automatic extraction of software identifier... von Ra'Fat Al-Msie'deen
Software evolution understanding: Automatic extraction of software identifier...Software evolution understanding: Automatic extraction of software identifier...
Software evolution understanding: Automatic extraction of software identifier...
Fleet Management Software in India von Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable12 views
FIMA 2023 Neo4j & FS - Entity Resolution.pptx von Neo4j
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptx
Neo4j17 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... von Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller42 views

Creating Unit Tests Using Genetic Programming

  • 1. Creating Unit Tests Using Genetic Programming Alexandre Bergel, Geraldine Galindo-Gutiérrez, Alison Fernandez-Blanco, Juan-Pablo Sandoval-Alcocer 🇨🇭RelationalAI 🇧🇴Universidad Católica Boliviana “San Pablo” 🇨🇱Ponti fi cia Universidad Católica de Chile https://bergel.eu
  • 2. Generating Unit Tests Contribute to making a software more reliable Ef fi cient at identifying bugs Used in prominent software companies Complement hand written tests Many techniques: fuzzingbook.org
  • 4. Genetic Algorithm Selection based on speed Reproduction Remplacement
  • 5. {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} {—— - - —- - -— —- —— -} Genetic Algorithm applied to tests Selection based on coverage Combination Remplacement
  • 6. Test as a chromosome {—— - - —- - -— —- —— -} v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := GCPoint new. v6 := v1 y. v7 := v3 negated. v8 := v5 add: v3.
  • 7. Test as a chromosome v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := GCPoint new. v6 := v1 y. v7 := v3 negated. v8 := v5 add: v3. The Genetic Algorithm searches for the optimal sequence of instructions to maximize the test coverage.
  • 8. Test as a chromosome v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := GCPoint new. v6 := v1 y. v7 := v3 negated. v8 := v5 add: v3. Two kinds of statements: - object construction - message send
  • 9. Test as a chromosome v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := GCPoint new. v6 := v1 y. v7 := v3 negated. v8 := v5 add: v3. Require a code example to extract argument type information. This is how correct arguments can be provided to message statements.
  • 10. Test as a chromosome v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := GCPoint new. v6 := v1 y. v7 := v3 negated. v8 := v5 add: v3. Some statements have requirements. A number is necessary to invoke x:y:
  • 11. Example of a mutation v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := GCPoint new 5. v6 := v1 y. v7 := v3 negated. v8 := v5 add: v3. The construction of a point is replaced by a construction of a number.
  • 12. Variable adjustment v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := GCPoint new 5. v6 := v1 y. v7 := v3 negated. v8 := v5 add: v3. v1 := GCPoint new. v2 := 4. v3 := v1 x: v2 y: v2. v4 := v3 negated. v5 := 5. v6 := v1 y. v7 := v3 negated. v8 := v3 add: v3.
  • 13. Future work Improvement of the test generation Be smarter to explore new code paths Compare SmallEvoTest with Pingüin for Python Visualize the evolution of tests
  • 15. Preliminary conclusion Pro fi ling an example to infer parameter types seems to give good results Base for future researches and experiments Available under the MIT License, for Pharo and GToolkit
  • 16. 🤗