Standard

To Mock or Not To Mock? An Empirical Study on Mocking Practices. / Spadini, Davide; Aniche, Maurício; Bruntink, Magiel; Bacchelli, Alberto.

Proceedings - 2017 IEEE/ACM 14th International Conference on Mining Software Repositories, MSR 2017. Los Alamitos, CA : IEEE Computer Society, 2017. p. 402-412 7962389.

Research output: Chapter in Book/Report/Conference proceedingConference contributionScientificpeer-review

Harvard

Spadini, D, Aniche, M, Bruntink, M & Bacchelli, A 2017, To Mock or Not To Mock? An Empirical Study on Mocking Practices. in Proceedings - 2017 IEEE/ACM 14th International Conference on Mining Software Repositories, MSR 2017., 7962389, IEEE Computer Society, Los Alamitos, CA, pp. 402-412, MSR 2017, Buenos Aires, Argentina, 20/05/17. https://doi.org/10.1109/MSR.2017.61

APA

Spadini, D., Aniche, M., Bruntink, M., & Bacchelli, A. (2017). To Mock or Not To Mock? An Empirical Study on Mocking Practices. In Proceedings - 2017 IEEE/ACM 14th International Conference on Mining Software Repositories, MSR 2017 (pp. 402-412). [7962389] Los Alamitos, CA: IEEE Computer Society. https://doi.org/10.1109/MSR.2017.61

Vancouver

Spadini D, Aniche M, Bruntink M, Bacchelli A. To Mock or Not To Mock? An Empirical Study on Mocking Practices. In Proceedings - 2017 IEEE/ACM 14th International Conference on Mining Software Repositories, MSR 2017. Los Alamitos, CA: IEEE Computer Society. 2017. p. 402-412. 7962389 https://doi.org/10.1109/MSR.2017.61

Author

Spadini, Davide ; Aniche, Maurício ; Bruntink, Magiel ; Bacchelli, Alberto. / To Mock or Not To Mock? An Empirical Study on Mocking Practices. Proceedings - 2017 IEEE/ACM 14th International Conference on Mining Software Repositories, MSR 2017. Los Alamitos, CA : IEEE Computer Society, 2017. pp. 402-412

BibTeX

@inproceedings{a0b02521ad004f969d9617a85dc23f99,
title = "To Mock or Not To Mock?: An Empirical Study on Mocking Practices",
abstract = "When writing automated unit tests, developers often deal with software artifacts that have several dependencies. In these cases, one has the possibility of either instantiating the dependencies or using mock objects to simulate the dependencies' expected behavior. Even though recent quantitative studies showed that mock objects are widely used in OSS projects, scientific knowledge is still lacking on how and why practitioners use mocks. Such a knowledge is fundamental to guide further research on this widespread practice and inform the design of tools and processes to improve it. The objective of this paper is to increase our understanding of which test dependencies developers (do not) mock and why, as well as what challenges developers face with this practice. To this aim, we create MOCKEXTRACTOR, a tool to mine the usage of mock objects in testing code and employ it to collect data from three OSS projects and one industrial system. Sampling from this data, we manually analyze how more than 2,000 test dependencies are treated. Subsequently, we discuss our findings with developers from these systems, identifying practices, rationales, and challenges. These results are supported by a structured survey with more than 100 professionals. The study reveals that the usage of mocks is highly dependent on the responsibility and the architectural concern of the class. Developers report to frequently mock dependencies that make testing difficult and prefer to not mock classes that encapsulate domain concepts/rules of the system. Among the key challenges, developers report that maintaining the behavior of the mock compatible with the behavior of original class is hard and that mocking increases the coupling between the test and the production code.",
keywords = "Testing, Java, Databases, Tools, Software systems, Interviews",
author = "Davide Spadini and Maur{\'i}cio Aniche and Magiel Bruntink and Alberto Bacchelli",
year = "2017",
doi = "10.1109/MSR.2017.61",
language = "English",
pages = "402--412",
booktitle = "Proceedings - 2017 IEEE/ACM 14th International Conference on Mining Software Repositories, MSR 2017",
publisher = "IEEE Computer Society",
address = "United States",

}

RIS

TY - GEN

T1 - To Mock or Not To Mock?

T2 - An Empirical Study on Mocking Practices

AU - Spadini, Davide

AU - Aniche, Maurício

AU - Bruntink, Magiel

AU - Bacchelli, Alberto

PY - 2017

Y1 - 2017

N2 - When writing automated unit tests, developers often deal with software artifacts that have several dependencies. In these cases, one has the possibility of either instantiating the dependencies or using mock objects to simulate the dependencies' expected behavior. Even though recent quantitative studies showed that mock objects are widely used in OSS projects, scientific knowledge is still lacking on how and why practitioners use mocks. Such a knowledge is fundamental to guide further research on this widespread practice and inform the design of tools and processes to improve it. The objective of this paper is to increase our understanding of which test dependencies developers (do not) mock and why, as well as what challenges developers face with this practice. To this aim, we create MOCKEXTRACTOR, a tool to mine the usage of mock objects in testing code and employ it to collect data from three OSS projects and one industrial system. Sampling from this data, we manually analyze how more than 2,000 test dependencies are treated. Subsequently, we discuss our findings with developers from these systems, identifying practices, rationales, and challenges. These results are supported by a structured survey with more than 100 professionals. The study reveals that the usage of mocks is highly dependent on the responsibility and the architectural concern of the class. Developers report to frequently mock dependencies that make testing difficult and prefer to not mock classes that encapsulate domain concepts/rules of the system. Among the key challenges, developers report that maintaining the behavior of the mock compatible with the behavior of original class is hard and that mocking increases the coupling between the test and the production code.

AB - When writing automated unit tests, developers often deal with software artifacts that have several dependencies. In these cases, one has the possibility of either instantiating the dependencies or using mock objects to simulate the dependencies' expected behavior. Even though recent quantitative studies showed that mock objects are widely used in OSS projects, scientific knowledge is still lacking on how and why practitioners use mocks. Such a knowledge is fundamental to guide further research on this widespread practice and inform the design of tools and processes to improve it. The objective of this paper is to increase our understanding of which test dependencies developers (do not) mock and why, as well as what challenges developers face with this practice. To this aim, we create MOCKEXTRACTOR, a tool to mine the usage of mock objects in testing code and employ it to collect data from three OSS projects and one industrial system. Sampling from this data, we manually analyze how more than 2,000 test dependencies are treated. Subsequently, we discuss our findings with developers from these systems, identifying practices, rationales, and challenges. These results are supported by a structured survey with more than 100 professionals. The study reveals that the usage of mocks is highly dependent on the responsibility and the architectural concern of the class. Developers report to frequently mock dependencies that make testing difficult and prefer to not mock classes that encapsulate domain concepts/rules of the system. Among the key challenges, developers report that maintaining the behavior of the mock compatible with the behavior of original class is hard and that mocking increases the coupling between the test and the production code.

KW - Testing

KW - Java

KW - Databases

KW - Tools

KW - Software systems

KW - Interviews

UR - http://resolver.tudelft.nl/uuid:a0b02521-ad00-4f96-9d96-17a85dc23f99

U2 - 10.1109/MSR.2017.61

DO - 10.1109/MSR.2017.61

M3 - Conference contribution

SP - 402

EP - 412

BT - Proceedings - 2017 IEEE/ACM 14th International Conference on Mining Software Repositories, MSR 2017

PB - IEEE Computer Society

CY - Los Alamitos, CA

ER -

ID: 13757225