SlideShare a Scribd company logo
1 of 51
Download to read offline
Test amplification tutorial with DSpot
Benjamin DANGLOT
December 14th
, 2017
benjamin.danglot@inria.fr
STAMP Workshop Atos - Madrid
1/21
Use Case Example
2/21
DSpot
DSpot: Principle
Program
Test suite
3/21
DSpot: Principle
×
Program
Test suite Test criterion
3/21
DSpot: Principle
DSpot
×
Program
Test suite Test criterion
3/21
DSpot: Principle
DSpot
×
Program
Test suite Test criterion
Amplified
test suite
3/21
DSpot: Principle
DSpot
Program
Test suite Test criterion
Amplified
test suite
3/21
Use Case Example
4/21
Test Example
5/21
Test Example
In blue, the input of the test
5/21
Test Example
In blue, the input of the test
In green, an oracle of the test to verify the current behavior
5/21
How DSpot works?
6/21
DSpot: 1. Input Modification
6/21
DSpot: 1. Input Modification
Modifies the input to create new state of the program
7/21
DSpot: 1. Input Modification
Removes a method call to create a new state of the program
Remove method
call
7/21
DSpot: 1. Input Modification
Removes a method call to create a new state of the program
7/21
DSpot: 1. Input Modification
Removes a method call to create a new state of the program
Before:
benjamin.isHungry() → false
After:
benjamin.isHungry() → true
7/21
DSpot: 2. Assertion Generation
8/21
DSpot: 2. Assertion Generation
Goal: Generate assertions to verify the state of the program
1. Remove existing assertions
2. Instrument the test
3. Run Instrumented test to collect values
4. Generate assertions based on values collected
9/21
DSpot: 2. Assertion Generation
A. Removes existing assertions
10/21
DSpot: 2. Assertion Generation
assertion
removed
A. Removes existing assertions
11/21
DSpot: 2. Assertion Generation
B. Instruments the code to gather new values
12/21
DSpot: 2. Assertion Generation
B. Instruments the code to gather new values
13/21
DSpot: 2. Assertion Generation
C. Runs the instrumented test and obtains observations
14/21
DSpot: 2. Assertion Generation
C. Runs the instrumented test and obtains observations
Observations:
benjamin.isHungry() → true
benjamin.isHappy() → false
15/21
DSpot: 2. Assertion Generation
D. Generates new assertions based on observations
Observations:
benjamin.isHungry() → true
benjamin.isHappy() → false
16/21
DSpot: 2. Assertion Generation
D. Generates new assertions based on observations
Observations:
benjamin.isHungry() → true
benjamin.isHappy() → false
17/21
DSpot: Amplification of Test Results
Original test
Amplified test
18/21
DSpot: Amplification of Test Results
Original test
Method call removed
Assertion
Generated
Amplified test
18/21
DSpot: 3. Test Selection
19/21
Pre-Requisite: Mutation Analysis
Test Suite
Program
The mutation analysis computes the mutation score, a measure of the
efficiency of tests
20/21
Mutation Analysis
Test Suite
Program
Variant 1
Test Suite
Program
Variant 1
Inject Fault
First, creates variants of program by injecting faults
20/21
Mutation Analysis
Test Suite
Program
Variant 1
Variant 2
Test Suite
Program
Variant 1
Variant 2Inject Fault
Inject Fault
First, creates variants of program by injecting faults
20/21
Mutation Analysis
Test Suite
Program
Variant 1
Variant 2
Variant 3
Test Suite
Program
Variant 1
Variant 2
Variant 3
Inject Fault
Inject Fault
Inject Fault
First, creates variants of program by injecting faults
20/21
Mutation Analysis
Test Suite
Program
Variant 1
Variant 2
Variant 3Run
Run
Run
Then, runs tests against each variant
20/21
Mutation Analysis
Test Suite
Program
Variant 1
Variant 2
Variant 3Run
Run
Run
Killed
Killed
Alive
Failing test ⇔ mutant killed ⇔ behavior variation detected
20/21
Selection Of Test Using Mutation Analysis
21/21
Selection Of Test Using Mutation Analysis
21/21
Selection Of Test Using Mutation Analysis
21/21
Selection Of Test Using Mutation Analysis
21/21
Selection Of Test Using Mutation Analysis
21/21
Selection Of Test Using Mutation Analysis
21/21
Selection Of Test Using Mutation Analysis
21/21
Selection Of Test Using Mutation Analysis
21/21
DSpot: iteration
22/21
DSpot: Try it
https://github.com/danglotb/tavern
23/21
DSpot: Command Line Options
https://github.com/danglotb/tavern
• --path-to-properties
src/main/resources/tavern.properties: general description of
the project
• --iteration 2: number of time that the main loop is applied
• --test fr.inria.stamp.MainTest: full qualified name of the
test class to be amplified
• --cases test: name of the test method (test case)
• --amplifiers TestDataMutator: used input modification
• --test-criterion PitMutantScoreSelector: test criterion
selector used
• --verbose: enable more logs
• --path-pit-result mutations results/original.csv: read
mutation analysis from file to speed up the exe
24/21
Input Modification: Available Operators
• Literal Modification
1. Add/Remove/Replace a char in String
2. replace by Random String
3. +1/−1/×2/÷2 values
4. replace by random/upper bound/lower bound value
5. negate boolean
• Method Call Duplication
• Method Call Deletion
• Generation of Method Call (and required objects)
25/21
Test Selection: Available Selector
• Mutation Score
• Branch Coverage
• Instruction Coverage and Execution Path
• Behavior Changes
26/21
DSpot: Playing With Command Line Options
https://github.com/danglotb/tavern
Input Modification
--amplifiers:
• MethodAdd: duplicate
method call
• MethodRemove: remove
method call
• TestDataMutator: mutate
literals
• StatementAdd: add
method call
Compose them using ’:’
Test Criterion Selector
--test-criterion:
• PitMutantScoreSelector:
increase mutation score
• JacocoCoverageSelector:
increase coverage/exec.
path
• TakeAllSelector: take all
amplified test
You can also play with
--iteration
27/21

More Related Content

Similar to DSpot - Test Amplification for Java

Continuous test suite failure prediction
Continuous test suite failure predictionContinuous test suite failure prediction
Continuous test suite failure prediction
ssuser94f898
 
CPSC 120Spring 2014Lab 5Name _____________________.docx
CPSC 120Spring 2014Lab 5Name _____________________.docxCPSC 120Spring 2014Lab 5Name _____________________.docx
CPSC 120Spring 2014Lab 5Name _____________________.docx
faithxdunce63732
 
Dynamic Symbolic Database Application Testing
Dynamic Symbolic Database Application TestingDynamic Symbolic Database Application Testing
Software testing ari force institute of tech.
Software testing ari force institute of tech.Software testing ari force institute of tech.
Software testing ari force institute of tech.
Sanjith Ml
 

Similar to DSpot - Test Amplification for Java (20)

Thesis Talk
Thesis TalkThesis Talk
Thesis Talk
 
Continuous test suite failure prediction
Continuous test suite failure predictionContinuous test suite failure prediction
Continuous test suite failure prediction
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Towards explanations for Data-Centric AI using provenance records
Towards explanations for Data-Centric AI using provenance recordsTowards explanations for Data-Centric AI using provenance records
Towards explanations for Data-Centric AI using provenance records
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
 
Repair dagstuhl jan2017
Repair dagstuhl jan2017Repair dagstuhl jan2017
Repair dagstuhl jan2017
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
CPSC 120Spring 2014Lab 5Name _____________________.docx
CPSC 120Spring 2014Lab 5Name _____________________.docxCPSC 120Spring 2014Lab 5Name _____________________.docx
CPSC 120Spring 2014Lab 5Name _____________________.docx
 
Chap07
Chap07Chap07
Chap07
 
Optimization techniques
Optimization techniquesOptimization techniques
Optimization techniques
 
Dynamic Symbolic Database Application Testing
Dynamic Symbolic Database Application TestingDynamic Symbolic Database Application Testing
Dynamic Symbolic Database Application Testing
 
Software testing ari force institute of tech.
Software testing ari force institute of tech.Software testing ari force institute of tech.
Software testing ari force institute of tech.
 
Nobody Knows What It’s Like To Be the Bad Man: The Development Process for th...
Nobody Knows What It’s Like To Be the Bad Man: The Development Process for th...Nobody Knows What It’s Like To Be the Bad Man: The Development Process for th...
Nobody Knows What It’s Like To Be the Bad Man: The Development Process for th...
 
A Performance Study of BDD-Based Model Checking
A Performance Study of BDD-Based Model CheckingA Performance Study of BDD-Based Model Checking
A Performance Study of BDD-Based Model Checking
 
Csphtp1 06
Csphtp1 06Csphtp1 06
Csphtp1 06
 
rlhf.pdf
rlhf.pdfrlhf.pdf
rlhf.pdf
 
Mux and demux done in cadence with pics
Mux and demux done in cadence with picsMux and demux done in cadence with pics
Mux and demux done in cadence with pics
 
Tech Days 2015: Dynamic Analysis
Tech Days 2015: Dynamic AnalysisTech Days 2015: Dynamic Analysis
Tech Days 2015: Dynamic Analysis
 
autoTVM
autoTVMautoTVM
autoTVM
 
Using Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelinesUsing Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelines
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

DSpot - Test Amplification for Java