SlideShare une entreprise Scribd logo
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

Contenu connexe

Tendances

3104328 software-testing-interview-questions
3104328 software-testing-interview-questions3104328 software-testing-interview-questions
3104328 software-testing-interview-questions
Raghavendra Kudal
 
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
 

Tendances (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
 

Similaire à To Mock or Not To Mock

Random testing & prototyping
Random testing & prototypingRandom testing & prototyping
Random testing & prototyping
Vipul Rastogi
 
Random testing & prototyping
Random testing & prototypingRandom testing & prototyping
Random testing & prototyping
Vipul Rastogi
 

Similaire à 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
 

Plus de Delft University of Technology

Plus de 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
 

Dernier

CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
Kamal Acharya
 
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdfDR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DrGurudutt
 

Dernier (20)

KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdf
 
A case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfA case study of cinema management system project report..pdf
A case study of cinema management system project report..pdf
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
 
Soil Testing Instruments by aimil ltd.- California Bearing Ratio apparatus, c...
Soil Testing Instruments by aimil ltd.- California Bearing Ratio apparatus, c...Soil Testing Instruments by aimil ltd.- California Bearing Ratio apparatus, c...
Soil Testing Instruments by aimil ltd.- California Bearing Ratio apparatus, c...
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdfDR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 

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?