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 sur 16

Recommandé

MT_01_unittest_python.pdf par
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdfHans Jones
16 vues26 diapositives
Rechecking SharpDevelop: Any New Bugs? par
Rechecking SharpDevelop: Any New Bugs?Rechecking SharpDevelop: Any New Bugs?
Rechecking SharpDevelop: Any New Bugs?PVS-Studio
71 vues9 diapositives
Altitude San Francisco 2018: Testing with Fastly Workshop par
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopFastly
181 vues66 diapositives
Errors detected in C++Builder par
Errors detected in C++BuilderErrors detected in C++Builder
Errors detected in C++BuilderPVS-Studio
334 vues7 diapositives
Long-Awaited Check of CryEngine V par
Long-Awaited Check of CryEngine VLong-Awaited Check of CryEngine V
Long-Awaited Check of CryEngine VPVS-Studio
80 vues25 diapositives
An Introduction to Property Based Testing par
An Introduction to Property Based TestingAn Introduction to Property Based Testing
An Introduction to Property Based TestingC4Media
498 vues93 diapositives

Contenu connexe

Similaire à Creating Unit Tests Using Genetic Programming

Leveling Up With Unit Testing - php[tek] 2023 par
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 vues75 diapositives
Source code of WPF samples by Microsoft was checked par
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 vues16 diapositives
yelp data challenge par
yelp data challengeyelp data challenge
yelp data challengeAMR koura
627 vues30 diapositives
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin... par
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 vues57 diapositives
Analyzing ReactOS One More Time par
Analyzing ReactOS One More TimeAnalyzing ReactOS One More Time
Analyzing ReactOS One More TimePVS-Studio
97 vues12 diapositives
Designing process flows with #Baker par
Designing process flows with #BakerDesigning process flows with #Baker
Designing process flows with #BakerBekir Oguz
1.4K vues79 diapositives

Similaire à Creating Unit Tests Using Genetic Programming(20)

Leveling Up With Unit Testing - php[tek] 2023 par 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 vues
Source code of WPF samples by Microsoft was checked par 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 vues
yelp data challenge par AMR koura
yelp data challengeyelp data challenge
yelp data challenge
AMR koura627 vues
A Practical Approach to Building a Streaming Processing Pipeline for an Onlin... par 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 vues
Analyzing ReactOS One More Time par PVS-Studio
Analyzing ReactOS One More TimeAnalyzing ReactOS One More Time
Analyzing ReactOS One More Time
PVS-Studio97 vues
Designing process flows with #Baker par Bekir Oguz
Designing process flows with #BakerDesigning process flows with #Baker
Designing process flows with #Baker
Bekir Oguz1.4K vues
Neal Gafter Java Evolution par deimos
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolution
deimos784 vues
Critical errors in CryEngine V code par PVS-Studio
Critical errors in CryEngine V codeCritical errors in CryEngine V code
Critical errors in CryEngine V code
PVS-Studio24 vues
Leveling Up With Unit Testing - LonghornPHP 2022 par Mark Niebergall
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
Mark Niebergall35 vues
Linux version of PVS-Studio couldn't help checking CodeLite par 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 vues
Windmill Testing certification par Vskills
Windmill Testing certificationWindmill Testing certification
Windmill Testing certification
Vskills430 vues
APIs and Synthetic Biology par Uri Laserson
APIs and Synthetic BiologyAPIs and Synthetic Biology
APIs and Synthetic Biology
Uri Laserson2.8K vues
Md university cmis 102 week 4 hands on lab new par 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 vues
Deep Parameters Tuning for Android Mobile Apps par 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 vues
Scikit-Learn: Machine Learning in Python par Microsoft
Scikit-Learn: Machine Learning in PythonScikit-Learn: Machine Learning in Python
Scikit-Learn: Machine Learning in Python
Microsoft4.5K vues

Plus de ESUG

Workshop: Identifying concept inventories in agile programming par
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
12 vues16 diapositives
Technical documentation support in Pharo par
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
50 vues39 diapositives
The Pharo Debugger and Debugging tools: Advances and Roadmap par
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
57 vues44 diapositives
Sequence: Pipeline modelling in Pharo par
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
87 vues22 diapositives
Migration process from monolithic to micro frontend architecture in mobile ap... par
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 vues35 diapositives
Analyzing Dart Language with Pharo: Report and early results par
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
108 vues30 diapositives

Plus de ESUG(20)

Workshop: Identifying concept inventories in agile programming par ESUG
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
ESUG12 vues
Technical documentation support in Pharo par ESUG
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
ESUG50 vues
The Pharo Debugger and Debugging tools: Advances and Roadmap par 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
ESUG57 vues
Sequence: Pipeline modelling in Pharo par ESUG
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
ESUG87 vues
Migration process from monolithic to micro frontend architecture in mobile ap... par 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 vues
Analyzing Dart Language with Pharo: Report and early results par 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
ESUG108 vues
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6 par 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
ESUG39 vues
A Unit Test Metamodel for Test Generation par ESUG
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
ESUG54 vues
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes par 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 vues
Exploring GitHub Actions through EGAD: An Experience Report par 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 vues
Pharo: a reflective language A first systematic analysis of reflective APIs par 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
ESUG58 vues
Garbage Collector Tuning par ESUG
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
ESUG20 vues
Improving Performance Through Object Lifetime Profiling: the DataFrame Case par 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 vues
Pharo DataFrame: Past, Present, and Future par ESUG
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG43 vues
thisContext in the Debugger par ESUG
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
ESUG36 vues
Websockets for Fencing Score par ESUG
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
ESUG18 vues
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript par 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 vues
Advanced Object- Oriented Design Mooc par ESUG
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
ESUG85 vues
A New Architecture Reconciling Refactorings and Transformations par ESUG
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
ESUG28 vues
BioSmalltalk par ESUG
BioSmalltalkBioSmalltalk
BioSmalltalk
ESUG415 vues

Dernier

Ports-and-Adapters Architecture for Embedded HMI par
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMIBurkhard Stubert
37 vues19 diapositives
Using Qt under LGPL-3.0 par
Using Qt under LGPL-3.0Using Qt under LGPL-3.0
Using Qt under LGPL-3.0Burkhard Stubert
15 vues11 diapositives
.NET Deserialization Attacks par
.NET Deserialization Attacks.NET Deserialization Attacks
.NET Deserialization AttacksDharmalingam Ganesan
7 vues50 diapositives
Supercharging your Python Development Environment with VS Code and Dev Contai... par
Supercharging your Python Development Environment with VS Code and Dev Contai...Supercharging your Python Development Environment with VS Code and Dev Contai...
Supercharging your Python Development Environment with VS Code and Dev Contai...Dawn Wages
9 vues51 diapositives
Benefits in Software Development par
Benefits in Software DevelopmentBenefits in Software Development
Benefits in Software DevelopmentJohn Valentino
7 vues15 diapositives
The Path to DevOps par
The Path to DevOpsThe Path to DevOps
The Path to DevOpsJohn Valentino
6 vues6 diapositives

Dernier(20)

Ports-and-Adapters Architecture for Embedded HMI par Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Supercharging your Python Development Environment with VS Code and Dev Contai... par Dawn Wages
Supercharging your Python Development Environment with VS Code and Dev Contai...Supercharging your Python Development Environment with VS Code and Dev Contai...
Supercharging your Python Development Environment with VS Code and Dev Contai...
Dawn Wages9 vues
Top-5-production-devconMunich-2023-v2.pptx par Tier1 app
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
Tier1 app9 vues
Google Solutions Challenge 2024 Talk pdf par MohdAbdulAleem4
Google Solutions Challenge 2024 Talk pdfGoogle Solutions Challenge 2024 Talk pdf
Google Solutions Challenge 2024 Talk pdf
MohdAbdulAleem447 vues
tecnologia18.docx par nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67026 vues
Transport Management System - Shipment & Container Tracking par Freightoscope
Transport Management System - Shipment & Container TrackingTransport Management System - Shipment & Container Tracking
Transport Management System - Shipment & Container Tracking
predicting-m3-devopsconMunich-2023.pptx par Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app10 vues

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. 🤗