SlideShare a Scribd company logo
1 of 28
Download to read offline
To Mock Or Not To Mock?
An Empirical Study on Mocking Practices
Davide Spadini, Mauricio Aniche, 

Magiel Bruntink, Alberto Bacchelli
@DavideSpadini
How do I test this?
With dependencies Without dependencies
Mock
Unit under testUnit under test
With dependencies
With dependencies
With dependencies
• Faster • Easier
Without dependencies
Without dependencies
You lose in reality, after all, it is
just a simulation!
To Mock Not to Mock
So, what should we do?
RQ1: What test dependencies do developers
mock?
RQ2: Why do developers decide to (not) mock
specific dependencies?
RQ3: Which are the main challenges
experienced with testing using mocks?
Research Questions
Opensource
Industrial
Methodology
TA
P1
Sonarqube
Alura
VRaptor
Spring Framework
TA
P1
TA
P1
TA
P1
Methodology
TA
MockExtractor
TA
P3
Mock
P1
P2
13,547 dependencies
P1
Sonarqube
TA
P3
Mock
P1
P2
1,665 dependencies
Alura
TA
P3
Mock
P1
P2
1,333 dependencies
VRaptor
TA
P3
Mock
P1
P2
21,768 dependencies
Spring Framework
TA
P1
TA
P1
TA
P1
Methodology
TA
MockExtractor
TA
P3
Mock
P1
P2
13,547 dependencies 674 dependencies
TA P1
Tn Pn
… …
Sampling
P1
Sonarqube
TA
P3
Mock
P1
P2
1,665 dependencies 445 dependencies
TA P1
Tn Pn
… …
Alura
TA
P3
Mock
P1
P2
1,333 dependencies 438 dependencies
TA P1
Tn Pn
… …
VRaptor
TA
P3
Mock
P1
P2
21,768 dependencies 621 dependencies
TA P1
Tn Pn
… …
Spring Framework
Data collection
TA
P1
TA
P1
TA
P1
Methodology
TA
MockExtractor
TA
P3
Mock
P1
P2
13,547 dependencies 674 dependencies
TA P1
Tn Pn
… …
Sampling
Sample 1
P1
Sonarqube
TA
P3
Mock
P1
P2
1,665 dependencies 445 dependencies
TA P1
Tn Pn
… …
Alura
TA
P3
Mock
P1
P2
1,333 dependencies 438 dependencies
TA P1
Tn Pn
… …
VRaptor
TA
P3
Mock
P1
P2
21,768 dependencies 621 dependencies
TA P1
Tn Pn
… …
Spring Framework
Sample 2
Validation
Manual analysis
(2nd author)
Manual analysis
(1st author)
Data analysisData collection
Manual analysis
TA
P1
TA
P1
TA
P1
Methodology
TA
MockExtractor
TA
P3
Mock
P1
P2
13,547 dependencies 674 dependencies
TA P1
Tn Pn
… …
Sampling
Commit
Comments
Commit
Comments
Commit
Comments
132
categories
Commit
Comments7
Categories
Sample 1
P1
Sonarqube
TA
P3
Mock
P1
P2
1,665 dependencies 445 dependencies
TA P1
Tn Pn
… …
Alura
TA
P3
Mock
P1
P2
1,333 dependencies 438 dependencies
TA P1
Tn Pn
… …
VRaptor
TA
P3
Mock
P1
P2
21,768 dependencies 621 dependencies
TA P1
Tn Pn
… …
Spring Framework
Sample 2
Validation
Manual analysis
(2nd author)
Manual analysis
(1st author)
Discussion
Data analysisData collection
Manual analysis Categorisation
TA
P1
TA
P1
TA
P1
Methodology
RQ1
RQ1: What test dependencies do developers mock?
RQ1: What test dependencies do developers mock?
RQ1
0%
25%
50%
75%
100%
Database Web service External 

Dependencies
Domain 

object
Java libraries Test support
94%93%64%32%31%28%
6%7%
36%
68%69%
72%
Mocked Not mocked
TA
MockExtractor
TA
P3
Mock
P1
P2
13,547 dependencies 674 dependencies
TA P1
Tn Pn
… …
Sampling
Commit
Comments
Commit
Comments
Commit
Comments
132
categories
Commit
Comments7
Categories
Interview
Guideline
3 developers
Sample 1
P1
Sonarqube
TA
P3
Mock
P1
P2
1,665 dependencies 445 dependencies
TA P1
Tn Pn
… …
Alura
TA
P3
Mock
P1
P2
1,333 dependencies 438 dependencies
TA P1
Tn Pn
… …
VRaptor
TA
P3
Mock
P1
P2
21,768 dependencies 621 dependencies
TA P1
Tn Pn
… …
Spring Framework
Sample 2
Validation
Manual analysis
(2nd author)
Manual analysis
(1st author)
Discussion
Data analysis
Interviews &
Validation
Data collection
Manual analysis Categorisation
TA
P1
TA
P1
TA
P1
Methodology
RQ2
RQ2: Why do developers decide to (not) mock a
dependency?
RQ2
RQ2: Why do developers decide to (not) mock a
dependency?
Not when the
focus of the
test is the
integration
Vehicle
Car Plane Boat
Mock interfaces
rather than a
specific
implementation
Concrete
implementation
is not easy
TA
MockExtractor
TA
P3
Mock
P1
P2
13,547 dependencies 674 dependencies
TA P1
Tn Pn
… …
Sampling
Commit
Comments
Commit
Comments
Commit
Comments
132
categories
Commit
Comments7
Categories
Interview
Guideline
3 developers Commit
Comments
Review
Comment
Commit
Comments
Interview
Transcript
Commit
Comments
Commit
Comments
Survey
(105 respondents)
Sample 1
P1
Sonarqube
TA
P3
Mock
P1
P2
1,665 dependencies 445 dependencies
TA P1
Tn Pn
… …
Alura
TA
P3
Mock
P1
P2
1,333 dependencies 438 dependencies
TA P1
Tn Pn
… …
VRaptor
TA
P3
Mock
P1
P2
21,768 dependencies 621 dependencies
TA P1
Tn Pn
… …
Spring Framework
Sample 2
Validation
Manual analysis
(2nd author)
Manual analysis
(1st author)
Discussion
Affinity Diagram
Data analysis
Interviews &
Validation
Data collection
Manual analysis Categorisation
TA
P1
TA
P1
TA
P1
Methodology
RQ3
RQ3:Which are the main challenges experienced
with testing using mocks?
RQ3
RQ3:Which are the main challenges experienced
with testing using mocks?
Legacy systems
Dealing with
coupling
Production quality
code vs
mocks
Discussion
Mockito developer
• He agreed on all the findings
• How Mockito can help?
• What Mockito is supposed to
do more?
Open questions
• Software quality vs mocks
• Are slow tests more mocked?
• How faster are tests with
mocks?
To Mock or Not To Mock

More Related Content

What's hot

Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Alexandre (Shura) Iline
 
ISTQB Certified Tester Exam Question Papers and Answers - 11
ISTQB Certified Tester Exam Question Papers and Answers - 11ISTQB Certified Tester Exam Question Papers and Answers - 11
ISTQB Certified Tester Exam Question Papers and Answers - 11BDDazza
 
Software Testing Interview Questions
Software Testing Interview QuestionsSoftware Testing Interview Questions
Software Testing Interview QuestionsTestbytes
 
CSUN 2018 Analyzing and Extending WCAG Beyond 3 Digits
CSUN 2018 Analyzing and Extending WCAG Beyond 3 DigitsCSUN 2018 Analyzing and Extending WCAG Beyond 3 Digits
CSUN 2018 Analyzing and Extending WCAG Beyond 3 DigitsBill Tyler
 
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
Static Analysis Techniques For Testing Application Security - Houston Tech FestStatic Analysis Techniques For Testing Application Security - Houston Tech Fest
Static Analysis Techniques For Testing Application Security - Houston Tech FestDenim Group
 
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...Andrea Francia
 
3104328 software-testing-interview-questions
3104328 software-testing-interview-questions3104328 software-testing-interview-questions
3104328 software-testing-interview-questionsRaghavendra Kudal
 
Enhancing Developer Productivity with Code Forensics
Enhancing Developer Productivity with Code ForensicsEnhancing Developer Productivity with Code Forensics
Enhancing Developer Productivity with Code ForensicsTechWell
 
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Atlassian
 
A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...
A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...
A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...Kevin Moran
 
What is Regression Testing?
What is Regression Testing?What is Regression Testing?
What is Regression Testing?Alan Richardson
 
How to improve code quality for iOS apps?
How to improve code quality for iOS apps?How to improve code quality for iOS apps?
How to improve code quality for iOS apps?Kate Semizhon
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Dinis Cruz
 
Sigma Open Tech Week: Bitter Truth About Software Security
Sigma Open Tech Week: Bitter Truth About Software SecuritySigma Open Tech Week: Bitter Truth About Software Security
Sigma Open Tech Week: Bitter Truth About Software SecurityVlad Styran
 
How to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot EnvironmentsHow to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot EnvironmentsDevOps.com
 
Testing softvamp techno solutions technical interview questions freshers (1)
Testing softvamp techno solutions technical interview questions freshers (1)Testing softvamp techno solutions technical interview questions freshers (1)
Testing softvamp techno solutions technical interview questions freshers (1)SoftvampTechnoSoluti
 

What's hot (20)

Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.
 
ISTQB Certified Tester Exam Question Papers and Answers - 11
ISTQB Certified Tester Exam Question Papers and Answers - 11ISTQB Certified Tester Exam Question Papers and Answers - 11
ISTQB Certified Tester Exam Question Papers and Answers - 11
 
Software Testing Interview Questions
Software Testing Interview QuestionsSoftware Testing Interview Questions
Software Testing Interview Questions
 
CSUN 2018 Analyzing and Extending WCAG Beyond 3 Digits
CSUN 2018 Analyzing and Extending WCAG Beyond 3 DigitsCSUN 2018 Analyzing and Extending WCAG Beyond 3 Digits
CSUN 2018 Analyzing and Extending WCAG Beyond 3 Digits
 
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
Static Analysis Techniques For Testing Application Security - Houston Tech FestStatic Analysis Techniques For Testing Application Security - Houston Tech Fest
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
 
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
 
3104328 software-testing-interview-questions
3104328 software-testing-interview-questions3104328 software-testing-interview-questions
3104328 software-testing-interview-questions
 
Enhancing Developer Productivity with Code Forensics
Enhancing Developer Productivity with Code ForensicsEnhancing Developer Productivity with Code Forensics
Enhancing Developer Productivity with Code Forensics
 
Shift left-testing
Shift left-testingShift left-testing
Shift left-testing
 
Do Bugs Reside in Complex Code?
Do Bugs Reside in Complex Code?Do Bugs Reside in Complex Code?
Do Bugs Reside in Complex Code?
 
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
 
A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...
A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...
A Large-Scale Empirical Comparison of Static and DynamicTest Case Prioritizat...
 
What is Regression Testing?
What is Regression Testing?What is Regression Testing?
What is Regression Testing?
 
How to improve code quality for iOS apps?
How to improve code quality for iOS apps?How to improve code quality for iOS apps?
How to improve code quality for iOS apps?
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
 
Static code analysis
Static code analysisStatic code analysis
Static code analysis
 
Sigma Open Tech Week: Bitter Truth About Software Security
Sigma Open Tech Week: Bitter Truth About Software SecuritySigma Open Tech Week: Bitter Truth About Software Security
Sigma Open Tech Week: Bitter Truth About Software Security
 
How to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot EnvironmentsHow to Manage the Risk of your Polyglot Environments
How to Manage the Risk of your Polyglot Environments
 
Testing softvamp techno solutions technical interview questions freshers (1)
Testing softvamp techno solutions technical interview questions freshers (1)Testing softvamp techno solutions technical interview questions freshers (1)
Testing softvamp techno solutions technical interview questions freshers (1)
 
VLSI testing and analysis
VLSI testing and analysisVLSI testing and analysis
VLSI testing and analysis
 

Similar to To Mock or Not To Mock

When Testing Meets Code Review: Why and How Developers Review Tests
When Testing Meets Code Review: Why and How Developers Review TestsWhen Testing Meets Code Review: Why and How Developers Review Tests
When Testing Meets Code Review: Why and How Developers Review TestsDelft University of Technology
 
An exploratory study of the state of practice of performance testing in Java-...
An exploratory study of the state of practice of performance testing in Java-...An exploratory study of the state of practice of performance testing in Java-...
An exploratory study of the state of practice of performance testing in Java-...corpaulbezemer
 
Automatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based ApproachAutomatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based ApproachJavier Canovas
 
Sumo Logic Cert Jam - Search Mastery
Sumo Logic Cert Jam - Search MasterySumo Logic Cert Jam - Search Mastery
Sumo Logic Cert Jam - Search MasterySumo Logic
 
Random testing & prototyping
Random testing & prototypingRandom testing & prototyping
Random testing & prototypingVipul Rastogi
 
Random testing & prototyping
Random testing & prototypingRandom testing & prototyping
Random testing & prototypingVipul Rastogi
 
DockerCon SF 2019 - TDD is Dead
DockerCon SF 2019 - TDD is DeadDockerCon SF 2019 - TDD is Dead
DockerCon SF 2019 - TDD is DeadKevin Crawley
 
Performance - a challenging craft
Performance  - a challenging craftPerformance  - a challenging craft
Performance - a challenging craftFabian Lange
 
The Evolution of a LabVIEW Developer
The Evolution of a LabVIEW DeveloperThe Evolution of a LabVIEW Developer
The Evolution of a LabVIEW DeveloperBryan Heslop
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowAdam Doyle
 
Maturing your path toward DevOps with Continuous Testing
Maturing your path toward DevOps with Continuous TestingMaturing your path toward DevOps with Continuous Testing
Maturing your path toward DevOps with Continuous TestingPerfecto Mobile
 
FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...
FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...
FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...SonjaChevre
 
How do Developers Test Android Applications?
How do Developers Test Android Applications?How do Developers Test Android Applications?
How do Developers Test Android Applications?Kevin Moran
 
Smarter Automation with Machine Learning & AI-Based Reporting
Smarter Automation with Machine Learning & AI-Based ReportingSmarter Automation with Machine Learning & AI-Based Reporting
Smarter Automation with Machine Learning & AI-Based ReportingPerfecto by Perforce
 
Sample Software Reclaim Model for 50,000 Users
Sample Software Reclaim Model for 50,000 UsersSample Software Reclaim Model for 50,000 Users
Sample Software Reclaim Model for 50,000 UsersAdvika Bhavsar
 
130719 sebastiano panichella - who is going to mentor newcomers in open sou...
130719   sebastiano panichella - who is going to mentor newcomers in open sou...130719   sebastiano panichella - who is going to mentor newcomers in open sou...
130719 sebastiano panichella - who is going to mentor newcomers in open sou...Ptidej Team
 
A confused tester in agile world finalversion
A confused tester in agile world finalversionA confused tester in agile world finalversion
A confused tester in agile world finalversionAshish Kumar
 

Similar to To Mock or Not To Mock (20)

When Testing Meets Code Review: Why and How Developers Review Tests
When Testing Meets Code Review: Why and How Developers Review TestsWhen Testing Meets Code Review: Why and How Developers Review Tests
When Testing Meets Code Review: Why and How Developers Review Tests
 
An exploratory study of the state of practice of performance testing in Java-...
An exploratory study of the state of practice of performance testing in Java-...An exploratory study of the state of practice of performance testing in Java-...
An exploratory study of the state of practice of performance testing in Java-...
 
Automatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based ApproachAutomatic Generation of Test Cases for REST APIs: a Specification-Based Approach
Automatic Generation of Test Cases for REST APIs: a Specification-Based Approach
 
Sumo Logic Cert Jam - Search Mastery
Sumo Logic Cert Jam - Search MasterySumo Logic Cert Jam - Search Mastery
Sumo Logic Cert Jam - Search Mastery
 
Random testing & prototyping
Random testing & prototypingRandom testing & prototyping
Random testing & prototyping
 
Random testing & prototyping
Random testing & prototypingRandom testing & prototyping
Random testing & prototyping
 
DockerCon SF 2019 - TDD is Dead
DockerCon SF 2019 - TDD is DeadDockerCon SF 2019 - TDD is Dead
DockerCon SF 2019 - TDD is Dead
 
Performance - a challenging craft
Performance  - a challenging craftPerformance  - a challenging craft
Performance - a challenging craft
 
The Evolution of a LabVIEW Developer
The Evolution of a LabVIEW DeveloperThe Evolution of a LabVIEW Developer
The Evolution of a LabVIEW Developer
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
 
Ra 011513-01-finalv3
Ra 011513-01-finalv3Ra 011513-01-finalv3
Ra 011513-01-finalv3
 
Testing in production
Testing in productionTesting in production
Testing in production
 
SIG-NOC Tools survey results
SIG-NOC Tools survey resultsSIG-NOC Tools survey results
SIG-NOC Tools survey results
 
Maturing your path toward DevOps with Continuous Testing
Maturing your path toward DevOps with Continuous TestingMaturing your path toward DevOps with Continuous Testing
Maturing your path toward DevOps with Continuous Testing
 
FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...
FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...
FOSDEM 2024 - Deploy Fast, Without Breaking Things: Level Up APIOps With Open...
 
How do Developers Test Android Applications?
How do Developers Test Android Applications?How do Developers Test Android Applications?
How do Developers Test Android Applications?
 
Smarter Automation with Machine Learning & AI-Based Reporting
Smarter Automation with Machine Learning & AI-Based ReportingSmarter Automation with Machine Learning & AI-Based Reporting
Smarter Automation with Machine Learning & AI-Based Reporting
 
Sample Software Reclaim Model for 50,000 Users
Sample Software Reclaim Model for 50,000 UsersSample Software Reclaim Model for 50,000 Users
Sample Software Reclaim Model for 50,000 Users
 
130719 sebastiano panichella - who is going to mentor newcomers in open sou...
130719   sebastiano panichella - who is going to mentor newcomers in open sou...130719   sebastiano panichella - who is going to mentor newcomers in open sou...
130719 sebastiano panichella - who is going to mentor newcomers in open sou...
 
A confused tester in agile world finalversion
A confused tester in agile world finalversionA confused tester in agile world finalversion
A confused tester in agile world finalversion
 

More from Delft University of Technology

Primers or Reminders? The Effects of Existing Review Comments on Code Review
Primers or Reminders? The Effects of Existing Review Comments on Code ReviewPrimers or Reminders? The Effects of Existing Review Comments on Code Review
Primers or Reminders? The Effects of Existing Review Comments on Code ReviewDelft University of Technology
 
PyDriller: Python Framework for Mining Software Repositories
PyDriller: Python Framework for Mining Software RepositoriesPyDriller: Python Framework for Mining Software Repositories
PyDriller: Python Framework for Mining Software RepositoriesDelft University of Technology
 
On The Relation of Test Smells to Software Code Quality
On The Relation of Test Smells to Software Code QualityOn The Relation of Test Smells to Software Code Quality
On The Relation of Test Smells to Software Code QualityDelft University of Technology
 

More from Delft University of Technology (6)

Investigating Severity Thresholds for Test Smells
Investigating Severity Thresholds for Test SmellsInvestigating Severity Thresholds for Test Smells
Investigating Severity Thresholds for Test Smells
 
Primers or Reminders? The Effects of Existing Review Comments on Code Review
Primers or Reminders? The Effects of Existing Review Comments on Code ReviewPrimers or Reminders? The Effects of Existing Review Comments on Code Review
Primers or Reminders? The Effects of Existing Review Comments on Code Review
 
Test-Driven Code Review: An Empirical Study
Test-Driven Code Review: An Empirical StudyTest-Driven Code Review: An Empirical Study
Test-Driven Code Review: An Empirical Study
 
Practices and Tools for Better Software Testing
Practices and Tools for  Better Software TestingPractices and Tools for  Better Software Testing
Practices and Tools for Better Software Testing
 
PyDriller: Python Framework for Mining Software Repositories
PyDriller: Python Framework for Mining Software RepositoriesPyDriller: Python Framework for Mining Software Repositories
PyDriller: Python Framework for Mining Software Repositories
 
On The Relation of Test Smells to Software Code Quality
On The Relation of Test Smells to Software Code QualityOn The Relation of Test Smells to Software Code Quality
On The Relation of Test Smells to Software Code Quality
 

Recently uploaded

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 

Recently uploaded (20)

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 

To Mock or Not To Mock

  • 1. To Mock Or Not To Mock? An Empirical Study on Mocking Practices Davide Spadini, Mauricio Aniche, 
 Magiel Bruntink, Alberto Bacchelli @DavideSpadini
  • 2. How do I test this?
  • 5.
  • 9. • Faster • Easier Without dependencies
  • 10. Without dependencies You lose in reality, after all, it is just a simulation!
  • 11. To Mock Not to Mock So, what should we do?
  • 12. RQ1: What test dependencies do developers mock? RQ2: Why do developers decide to (not) mock specific dependencies? RQ3: Which are the main challenges experienced with testing using mocks? Research Questions
  • 15. TA MockExtractor TA P3 Mock P1 P2 13,547 dependencies P1 Sonarqube TA P3 Mock P1 P2 1,665 dependencies Alura TA P3 Mock P1 P2 1,333 dependencies VRaptor TA P3 Mock P1 P2 21,768 dependencies Spring Framework TA P1 TA P1 TA P1 Methodology
  • 16. TA MockExtractor TA P3 Mock P1 P2 13,547 dependencies 674 dependencies TA P1 Tn Pn … … Sampling P1 Sonarqube TA P3 Mock P1 P2 1,665 dependencies 445 dependencies TA P1 Tn Pn … … Alura TA P3 Mock P1 P2 1,333 dependencies 438 dependencies TA P1 Tn Pn … … VRaptor TA P3 Mock P1 P2 21,768 dependencies 621 dependencies TA P1 Tn Pn … … Spring Framework Data collection TA P1 TA P1 TA P1 Methodology
  • 17. TA MockExtractor TA P3 Mock P1 P2 13,547 dependencies 674 dependencies TA P1 Tn Pn … … Sampling Sample 1 P1 Sonarqube TA P3 Mock P1 P2 1,665 dependencies 445 dependencies TA P1 Tn Pn … … Alura TA P3 Mock P1 P2 1,333 dependencies 438 dependencies TA P1 Tn Pn … … VRaptor TA P3 Mock P1 P2 21,768 dependencies 621 dependencies TA P1 Tn Pn … … Spring Framework Sample 2 Validation Manual analysis (2nd author) Manual analysis (1st author) Data analysisData collection Manual analysis TA P1 TA P1 TA P1 Methodology
  • 18. TA MockExtractor TA P3 Mock P1 P2 13,547 dependencies 674 dependencies TA P1 Tn Pn … … Sampling Commit Comments Commit Comments Commit Comments 132 categories Commit Comments7 Categories Sample 1 P1 Sonarqube TA P3 Mock P1 P2 1,665 dependencies 445 dependencies TA P1 Tn Pn … … Alura TA P3 Mock P1 P2 1,333 dependencies 438 dependencies TA P1 Tn Pn … … VRaptor TA P3 Mock P1 P2 21,768 dependencies 621 dependencies TA P1 Tn Pn … … Spring Framework Sample 2 Validation Manual analysis (2nd author) Manual analysis (1st author) Discussion Data analysisData collection Manual analysis Categorisation TA P1 TA P1 TA P1 Methodology
  • 19. RQ1 RQ1: What test dependencies do developers mock?
  • 20. RQ1: What test dependencies do developers mock? RQ1 0% 25% 50% 75% 100% Database Web service External 
 Dependencies Domain 
 object Java libraries Test support 94%93%64%32%31%28% 6%7% 36% 68%69% 72% Mocked Not mocked
  • 21. TA MockExtractor TA P3 Mock P1 P2 13,547 dependencies 674 dependencies TA P1 Tn Pn … … Sampling Commit Comments Commit Comments Commit Comments 132 categories Commit Comments7 Categories Interview Guideline 3 developers Sample 1 P1 Sonarqube TA P3 Mock P1 P2 1,665 dependencies 445 dependencies TA P1 Tn Pn … … Alura TA P3 Mock P1 P2 1,333 dependencies 438 dependencies TA P1 Tn Pn … … VRaptor TA P3 Mock P1 P2 21,768 dependencies 621 dependencies TA P1 Tn Pn … … Spring Framework Sample 2 Validation Manual analysis (2nd author) Manual analysis (1st author) Discussion Data analysis Interviews & Validation Data collection Manual analysis Categorisation TA P1 TA P1 TA P1 Methodology
  • 22. RQ2 RQ2: Why do developers decide to (not) mock a dependency?
  • 23. RQ2 RQ2: Why do developers decide to (not) mock a dependency? Not when the focus of the test is the integration Vehicle Car Plane Boat Mock interfaces rather than a specific implementation Concrete implementation is not easy
  • 24. TA MockExtractor TA P3 Mock P1 P2 13,547 dependencies 674 dependencies TA P1 Tn Pn … … Sampling Commit Comments Commit Comments Commit Comments 132 categories Commit Comments7 Categories Interview Guideline 3 developers Commit Comments Review Comment Commit Comments Interview Transcript Commit Comments Commit Comments Survey (105 respondents) Sample 1 P1 Sonarqube TA P3 Mock P1 P2 1,665 dependencies 445 dependencies TA P1 Tn Pn … … Alura TA P3 Mock P1 P2 1,333 dependencies 438 dependencies TA P1 Tn Pn … … VRaptor TA P3 Mock P1 P2 21,768 dependencies 621 dependencies TA P1 Tn Pn … … Spring Framework Sample 2 Validation Manual analysis (2nd author) Manual analysis (1st author) Discussion Affinity Diagram Data analysis Interviews & Validation Data collection Manual analysis Categorisation TA P1 TA P1 TA P1 Methodology
  • 25. RQ3 RQ3:Which are the main challenges experienced with testing using mocks?
  • 26. RQ3 RQ3:Which are the main challenges experienced with testing using mocks? Legacy systems Dealing with coupling Production quality code vs mocks
  • 27. Discussion Mockito developer • He agreed on all the findings • How Mockito can help? • What Mockito is supposed to do more? Open questions • Software quality vs mocks • Are slow tests more mocked? • How faster are tests with mocks?