SlideShare a Scribd company logo
1 of 23
Download to read offline
1
1
1
Evref
fervE
A Unit Test Metamodel
for Test Generation
Gabriel Darbord¹
Anne Etien¹
Nicolas Anquetil¹
Benoit Verhaeghe²
Mustapha Derras²
¹Univ. Lille, CNRS, Inria, Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France
²Berger-Levrault, France
IWST 2023
Evref
fervE
2
2
2
Evref
fervE
The Importance of Testing
§ Nowadays, when developping new software systems:
§ 20-50% time spent on testing
§ We test because we want:
§ Bug detection and prevention
§ Quality assurance
§ User satisfaction
§ Non-regression
§ Confidence
§ Etc.
3
3
3
Evref
fervE
Legacy Software System Lack Tests
§ In 2022, Berger-Levrault owns 150 software programs
§ Three-tier architectures (client, server, database)
§ Millions of lines of code
§ Different legacy technologies that can be up to 25 years old
§ Severe lack of tests
§ Developers fear changes
4
4
4
Evref
fervE
Towards Automated Test Generation
§ Berger-Levrault wants tests for their legacy software
§ Impossible to write them manually
§ Time consuming
§ Difficult and error-prone
§ Lack of resources
5
5
5
Evref
fervE
Our Test Generation Approach
§ Using software models and execution traces
§ static and dynamic analysis
§ Our objective is to generate tests that are:
§ Relevant
§ Readable
§ Maintainable
§ Not relying on existing tests
6
6
6
Evref
fervE
Different Criteria
Paper Relevant Readable Maintainable
J. Pires et al. ~ ~ +
G. Fraser et al. ~ - ~
A. C. R. Paiva et al. + ~ ~
M. Tufano et al. ~ + ~
LLM approaches need to be trained on codebase and existing tests
7
7
7
Evref
fervE
About the Moose Platform
§ Moose is a platform for software analysis
§ It allows to:
§ Represent a software system in a model
§ Query, manipulate, transform, and visualize models
8
8
8
Evref
fervE
An Approach Based on Metamodels
Codebase Traces
Value
Model
Code
Model
Unit Test
Model
Unit Test
M0
Reality
M1
Models
M2
Metamodels
Value
Metamodel
Code
Metamodel
Unit Test
Metamodel
analyze extract generate
build
conformsTo conformsTo conformsTo
produce
9
9
9
Evref
fervE
Unit Test Metamodel
TestSuite TestCase TestMethod
Fixture
SetUp
TearDown Assertion
before
beforeAll
beforeEach
cleanups
arrangements
*
Value
*
* *
*
*
expected
arguments
valuesToHandle
Class Method
*
testedClass testedMethod
* unitTests
Act
after
afterAll
afterEach
* *
*
10
10
10
Evref
fervE
Value Metamodel
Value
Dictionary Primitive
Collection Object
EnumValue
Unknown
Association
dictionaryValue
dictionaryKey
* *
*
*
attributes
*
references
*
*
*
*
capturedValues
UnknownType
Type
TypedEntity
EnumValue
*
elements
source
11
11
11
Evref
fervE
Example Value Model
[{"name": "John Doe"}]
Set<User> getUsers()
Produces trace Modelized
Code
Value
"John Doe"
:Primitive
:Collection
:Object
HashSet<User>
:Type
getUsers()
:TypedEntity
User :Type
String :Type
name
source
type
type
type
12
12
12
Evref
fervE
Build Unit Test Using Model Transformations
Code
Model
Method
Parameter
Class
Unit Test
Model
TestCase
TestMethod
Arrange
Act
Assert
Value
Model
Argument
Result
13
13
13
Evref
fervE
Build Unit Test Using Model Transformations
Code
Model
Method
Parameter
Class
Unit Test
Model
TestCase
TestMethod
Arrange
Act
Assert
Value
Model
Argument
Result
14
14
14
Evref
fervE
Build Unit Test Using Model Transformations
Code
Model
Method
Parameter
Class
Unit Test
Model
TestCase
TestMethod
Arrange
Act
Assert
Value
Model
Argument
Result
15
15
15
Evref
fervE
Build Unit Test Using Model Transformations
Code
Model
Method
Parameter
Class
Unit Test
Model
TestCase
TestMethod
Arrange
Act
Assert
Value
Model
Argument
Result
16
16
16
Evref
fervE
Build Unit Test Using Model Transformations
Code
Model
Method
Parameter
Class
Unit Test
Model
TestCase
TestMethod
Arrange
Act
Assert
Value
Model
Argument
Result
17
17
17
Evref
fervE
Build Unit Test Using Model Transformations
Code
Model
Method
Parameter
Class
Unit Test
Model
TestCase
TestMethod
Arrange
Act
Assert
Value
Model
Argument
Result
18
18
18
Evref
fervE
Export Code Using Abstract Syntax Trees
M0
Reality
M1
Models
M2
Metamodels
Unit Test
Model
Unit Test
Metamodel
conformsTo
AST
Metamodel
AST
Model
Unit Test
conformsTo
export refactor
generate
19
19
19
Evref
fervE
Refactoring Abstract Syntax Trees
Statements
VarDecl
Variable
name
Primitive
"John Doe"
MethodCall
setName
Variable
user
Variable
name
String name = "John Doe";
user.setName(name);
20
20
20
Evref
fervE
Refactoring Abstract Syntax Trees
Statements
VarDecl
Variable
name
Primitive
"John Doe"
MethodCall
setName
Variable
user
Variable
name
Statements
Primitive
"John Doe"
MethodCall
setName
Variable
user
Inline constants
String name = "John Doe";
user.setName(name);
user.setName("John Doe");
21
21
21
Evref
fervE
Example of Generated Test for JUnit
class UserManager {
Set<User> users;
Set<User> usersByName(String name) {
Set<User> result = new HashSet<>();
for (User user: users)
if (user.getName().equals(name))
result.add(user);
return result;
}
}
class UserManagerTest {
UserManager manager = new UserManager();
@Test void testUsersByName() {
Set<User> expected = new HashSet<>();
User user = new User();
user.setName("John Doe");
expected.add(user);
Set<User> actual = manager
.usersByName("John Doe");
assertEquals(expected, actual);
}
}
Application code Generated test code
22
22
22
Evref
fervE
Future Work
§ Pursue test quality
§ Relevant, readable, maintainable…
§ Evaluate our approach in Pharo, thanks to our community
§ Compare existing tests to generated tests
§ Generate unit tests for our industrial partner Berger-Levrault
UT
23
23
23
Evref
fervE
8
8
8
Evref
fervE
An Approach Based on Metamodels
Codebase Traces
Value
Model
Code
Model
Unit Test
Model
Unit Test
M0
Reality
M1
Models
M2
Metamodels
Value
Metamodel
Code
Metamodel
Unit Test
Metamodel
analyze extract generate
build
conformsTo conformsTo conformsTo
produce
21
21
21
Evref
fervE
Example of Generated Test for JUnit
class UserManager {
Set<User> users;
Set<User> usersByName(String name) {
Set<User> result = new HashSet<>();
for (User user: users)
if (user.getName().equals(name))
result.add(user);
return result;
}
}
class UserManagerTest {
UserManager manager = new UserManager();
@Test void testUsersByName() {
Set<User> expected = new HashSet<>();
User user = new User();
user.setName("John Doe");
expected.add(user);
Set<User> actual = manager
.usersByName("John Doe");
assertEquals(expected, actual);
}
}
Application code Generated test code
5
5
5
Evref
fervE
Our Test Generation Approach
§ Using software models and execution traces
§ static and dynamic analysis
§ Our objective is to generate tests that are:
§ Relevant
§ Readable
§ Maintainable
§ Not relying on existing tests
9
9
9
Evref
fervE
Unit Test Metamodel
TestSuite TestCase TestMethod
Fixture
SetUp
TearDown Assertion
before
beforeAll
beforeEach
cleanups
arrangements
*
Value
*
* *
*
*
expected
arguments
valuesToHandle
Class Method
*
testedClass testedMethod
* unitTests
Act
after
afterAll
afterEach
* *
*
Conclusion

More Related Content

Similar to A Unit Test Metamodel for Test Generation

Software Testing Tools Training
Software Testing Tools TrainingSoftware Testing Tools Training
Software Testing Tools TrainingQEdge Tech
 
Software testing: an introduction - 2015
Software testing: an introduction - 2015Software testing: an introduction - 2015
Software testing: an introduction - 2015XavierDevroey
 
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...GeeksLab Odessa
 
GPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators FamiliesGPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators FamiliesMohamed BOUSSAA
 
Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...
Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...
Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...IncQuery Labs
 
Search-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing SystemsSearch-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing SystemsLionel Briand
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Codeerikmsp
 
Continuous Delivery with a PaaS Application
Continuous Delivery with a PaaS ApplicationContinuous Delivery with a PaaS Application
Continuous Delivery with a PaaS ApplicationMark Rendell
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Mark Niebergall
 
Verify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e testsVerify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e testsKen'ichi Ohmichi
 
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...Iosif Itkin
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
 
Unit testing
Unit testing Unit testing
Unit testing dubbu
 
Leveraging Existing Tests in Automated Test Generation for Web Applications
Leveraging Existing Tests in Automated Test Generation for Web ApplicationsLeveraging Existing Tests in Automated Test Generation for Web Applications
Leveraging Existing Tests in Automated Test Generation for Web ApplicationsSALT Lab @ UBC
 
Continuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsContinuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsMark Rendell
 
SPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePoint
SPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePointSPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePoint
SPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePointNCCOMMS
 
Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)Kevin Schultz
 
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't SuckDeliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't SuckKevin Brockhoff
 
Testing: Do More With Less
Testing: Do More With LessTesting: Do More With Less
Testing: Do More With LessEugene Fidelin
 

Similar to A Unit Test Metamodel for Test Generation (20)

Software Testing Tools Training
Software Testing Tools TrainingSoftware Testing Tools Training
Software Testing Tools Training
 
Software testing: an introduction - 2015
Software testing: an introduction - 2015Software testing: an introduction - 2015
Software testing: an introduction - 2015
 
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
 
GPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators FamiliesGPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators Families
 
Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...
Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...
Towards Scalable Validation of Low-Code System Models: Mapping EVL to VIATRA ...
 
Search-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing SystemsSearch-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing Systems
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Code
 
Continuous Delivery with a PaaS Application
Continuous Delivery with a PaaS ApplicationContinuous Delivery with a PaaS Application
Continuous Delivery with a PaaS Application
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
 
Verify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e testsVerify Your Kubernetes Clusters with Upstream e2e tests
Verify Your Kubernetes Clusters with Upstream e2e tests
 
FV04_MostoviczT_RAD
FV04_MostoviczT_RADFV04_MostoviczT_RAD
FV04_MostoviczT_RAD
 
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Unit testing
Unit testing Unit testing
Unit testing
 
Leveraging Existing Tests in Automated Test Generation for Web Applications
Leveraging Existing Tests in Automated Test Generation for Web ApplicationsLeveraging Existing Tests in Automated Test Generation for Web Applications
Leveraging Existing Tests in Automated Test Generation for Web Applications
 
Continuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsContinuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations Teams
 
SPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePoint
SPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePointSPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePoint
SPCA2013 - Taking advantage of Visual Studio to develop Apps for SharePoint
 
Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)
 
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't SuckDeliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
 
Testing: Do More With Less
Testing: Do More With LessTesting: Do More With Less
Testing: Do More With Less
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
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
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
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...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
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
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
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 6ESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
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 ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
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 APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
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 CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
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 JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 
BioSmalltalk
BioSmalltalkBioSmalltalk
BioSmalltalkESUG
 

More from ESUG (20)

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

Recently uploaded

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 

Recently uploaded (20)

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 

A Unit Test Metamodel for Test Generation

  • 1. 1 1 1 Evref fervE A Unit Test Metamodel for Test Generation Gabriel Darbord¹ Anne Etien¹ Nicolas Anquetil¹ Benoit Verhaeghe² Mustapha Derras² ¹Univ. Lille, CNRS, Inria, Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France ²Berger-Levrault, France IWST 2023 Evref fervE
  • 2. 2 2 2 Evref fervE The Importance of Testing § Nowadays, when developping new software systems: § 20-50% time spent on testing § We test because we want: § Bug detection and prevention § Quality assurance § User satisfaction § Non-regression § Confidence § Etc.
  • 3. 3 3 3 Evref fervE Legacy Software System Lack Tests § In 2022, Berger-Levrault owns 150 software programs § Three-tier architectures (client, server, database) § Millions of lines of code § Different legacy technologies that can be up to 25 years old § Severe lack of tests § Developers fear changes
  • 4. 4 4 4 Evref fervE Towards Automated Test Generation § Berger-Levrault wants tests for their legacy software § Impossible to write them manually § Time consuming § Difficult and error-prone § Lack of resources
  • 5. 5 5 5 Evref fervE Our Test Generation Approach § Using software models and execution traces § static and dynamic analysis § Our objective is to generate tests that are: § Relevant § Readable § Maintainable § Not relying on existing tests
  • 6. 6 6 6 Evref fervE Different Criteria Paper Relevant Readable Maintainable J. Pires et al. ~ ~ + G. Fraser et al. ~ - ~ A. C. R. Paiva et al. + ~ ~ M. Tufano et al. ~ + ~ LLM approaches need to be trained on codebase and existing tests
  • 7. 7 7 7 Evref fervE About the Moose Platform § Moose is a platform for software analysis § It allows to: § Represent a software system in a model § Query, manipulate, transform, and visualize models
  • 8. 8 8 8 Evref fervE An Approach Based on Metamodels Codebase Traces Value Model Code Model Unit Test Model Unit Test M0 Reality M1 Models M2 Metamodels Value Metamodel Code Metamodel Unit Test Metamodel analyze extract generate build conformsTo conformsTo conformsTo produce
  • 9. 9 9 9 Evref fervE Unit Test Metamodel TestSuite TestCase TestMethod Fixture SetUp TearDown Assertion before beforeAll beforeEach cleanups arrangements * Value * * * * * expected arguments valuesToHandle Class Method * testedClass testedMethod * unitTests Act after afterAll afterEach * * *
  • 10. 10 10 10 Evref fervE Value Metamodel Value Dictionary Primitive Collection Object EnumValue Unknown Association dictionaryValue dictionaryKey * * * * attributes * references * * * * capturedValues UnknownType Type TypedEntity EnumValue * elements source
  • 11. 11 11 11 Evref fervE Example Value Model [{"name": "John Doe"}] Set<User> getUsers() Produces trace Modelized Code Value "John Doe" :Primitive :Collection :Object HashSet<User> :Type getUsers() :TypedEntity User :Type String :Type name source type type type
  • 12. 12 12 12 Evref fervE Build Unit Test Using Model Transformations Code Model Method Parameter Class Unit Test Model TestCase TestMethod Arrange Act Assert Value Model Argument Result
  • 13. 13 13 13 Evref fervE Build Unit Test Using Model Transformations Code Model Method Parameter Class Unit Test Model TestCase TestMethod Arrange Act Assert Value Model Argument Result
  • 14. 14 14 14 Evref fervE Build Unit Test Using Model Transformations Code Model Method Parameter Class Unit Test Model TestCase TestMethod Arrange Act Assert Value Model Argument Result
  • 15. 15 15 15 Evref fervE Build Unit Test Using Model Transformations Code Model Method Parameter Class Unit Test Model TestCase TestMethod Arrange Act Assert Value Model Argument Result
  • 16. 16 16 16 Evref fervE Build Unit Test Using Model Transformations Code Model Method Parameter Class Unit Test Model TestCase TestMethod Arrange Act Assert Value Model Argument Result
  • 17. 17 17 17 Evref fervE Build Unit Test Using Model Transformations Code Model Method Parameter Class Unit Test Model TestCase TestMethod Arrange Act Assert Value Model Argument Result
  • 18. 18 18 18 Evref fervE Export Code Using Abstract Syntax Trees M0 Reality M1 Models M2 Metamodels Unit Test Model Unit Test Metamodel conformsTo AST Metamodel AST Model Unit Test conformsTo export refactor generate
  • 19. 19 19 19 Evref fervE Refactoring Abstract Syntax Trees Statements VarDecl Variable name Primitive "John Doe" MethodCall setName Variable user Variable name String name = "John Doe"; user.setName(name);
  • 20. 20 20 20 Evref fervE Refactoring Abstract Syntax Trees Statements VarDecl Variable name Primitive "John Doe" MethodCall setName Variable user Variable name Statements Primitive "John Doe" MethodCall setName Variable user Inline constants String name = "John Doe"; user.setName(name); user.setName("John Doe");
  • 21. 21 21 21 Evref fervE Example of Generated Test for JUnit class UserManager { Set<User> users; Set<User> usersByName(String name) { Set<User> result = new HashSet<>(); for (User user: users) if (user.getName().equals(name)) result.add(user); return result; } } class UserManagerTest { UserManager manager = new UserManager(); @Test void testUsersByName() { Set<User> expected = new HashSet<>(); User user = new User(); user.setName("John Doe"); expected.add(user); Set<User> actual = manager .usersByName("John Doe"); assertEquals(expected, actual); } } Application code Generated test code
  • 22. 22 22 22 Evref fervE Future Work § Pursue test quality § Relevant, readable, maintainable… § Evaluate our approach in Pharo, thanks to our community § Compare existing tests to generated tests § Generate unit tests for our industrial partner Berger-Levrault UT
  • 23. 23 23 23 Evref fervE 8 8 8 Evref fervE An Approach Based on Metamodels Codebase Traces Value Model Code Model Unit Test Model Unit Test M0 Reality M1 Models M2 Metamodels Value Metamodel Code Metamodel Unit Test Metamodel analyze extract generate build conformsTo conformsTo conformsTo produce 21 21 21 Evref fervE Example of Generated Test for JUnit class UserManager { Set<User> users; Set<User> usersByName(String name) { Set<User> result = new HashSet<>(); for (User user: users) if (user.getName().equals(name)) result.add(user); return result; } } class UserManagerTest { UserManager manager = new UserManager(); @Test void testUsersByName() { Set<User> expected = new HashSet<>(); User user = new User(); user.setName("John Doe"); expected.add(user); Set<User> actual = manager .usersByName("John Doe"); assertEquals(expected, actual); } } Application code Generated test code 5 5 5 Evref fervE Our Test Generation Approach § Using software models and execution traces § static and dynamic analysis § Our objective is to generate tests that are: § Relevant § Readable § Maintainable § Not relying on existing tests 9 9 9 Evref fervE Unit Test Metamodel TestSuite TestCase TestMethod Fixture SetUp TearDown Assertion before beforeAll beforeEach cleanups arrangements * Value * * * * * expected arguments valuesToHandle Class Method * testedClass testedMethod * unitTests Act after afterAll afterEach * * * Conclusion