Assessing mock classes: an empirical study

Detalhes bibliográficos
Autor(a) principal: Gustavo Henrique Alves Pereira
Data de Publicação: 2021
Tipo de documento: Dissertação
Idioma: eng
Título da fonte: Repositório Institucional da UFMG
Texto Completo: http://hdl.handle.net/1843/39045
Resumo: During testing activities, developers frequently rely on dependencies that make the test harder to be implemented. In this scenario, they can use mock objects to emulate the dependencies’ behavior, which contributes to make the test fast and isolated. In practice, the emulated dependency can be dynamically created with the support of mocking frameworks or manually hand-coded in mock classes. While the former is well-explored by the research literature, the latter lacks further empirical analysis. Assessing mock classes would provide the basis to better understand how those mocks are created and consumed by developers and to detect novel practices and challenges. In this dissertation, we propose an empirical and a survey study to assess mock classes. We analyze popular Java software projects, detect over 600 mock classes, and assess their content, design, evolution, and usage. We also conduct a survey with 39 developers who maintained mock classes to better understand usage motivations. We find that mock classes: often emulate domain objects, external dependencies, and web services; are typically part of a hierarchy; are mostly public (but 1/3 are private); and are largely consumed by client projects, particularly to support web testing. Developers argue that mocking frameworks may reduce code quality and have limitations, while mock classes may improve code quality and are simple to set up in tests. Moreover, developers state several reasons to create mock classes, for example, for complex testing and to support reuse; mocking frameworks should ideally be used to create simple unit tests, but also to test external entities and to test code with minimal change. The overall perception is that the usage of mock classes is preferable over mocking frameworks, however, there are specific cases in which mocking frameworks are a better choice. Finally, we provide implications and insights to researchers and practitioners working with mock classes.
id UFMG_48b143171cef992b3a72c01c32b431b7
oai_identifier_str oai:repositorio.ufmg.br:1843/39045
network_acronym_str UFMG
network_name_str Repositório Institucional da UFMG
repository_id_str
spelling André Cavalcante Horahttp://lattes.cnpq.br/4957418183504876Marco Túlio de Oliveira ValenteBruno Barbieri de Pontes Cafeohttp://lattes.cnpq.br/1376400389578607Gustavo Henrique Alves Pereira2022-01-08T02:46:07Z2022-01-08T02:46:07Z2021-09-02http://hdl.handle.net/1843/39045During testing activities, developers frequently rely on dependencies that make the test harder to be implemented. In this scenario, they can use mock objects to emulate the dependencies’ behavior, which contributes to make the test fast and isolated. In practice, the emulated dependency can be dynamically created with the support of mocking frameworks or manually hand-coded in mock classes. While the former is well-explored by the research literature, the latter lacks further empirical analysis. Assessing mock classes would provide the basis to better understand how those mocks are created and consumed by developers and to detect novel practices and challenges. In this dissertation, we propose an empirical and a survey study to assess mock classes. We analyze popular Java software projects, detect over 600 mock classes, and assess their content, design, evolution, and usage. We also conduct a survey with 39 developers who maintained mock classes to better understand usage motivations. We find that mock classes: often emulate domain objects, external dependencies, and web services; are typically part of a hierarchy; are mostly public (but 1/3 are private); and are largely consumed by client projects, particularly to support web testing. Developers argue that mocking frameworks may reduce code quality and have limitations, while mock classes may improve code quality and are simple to set up in tests. Moreover, developers state several reasons to create mock classes, for example, for complex testing and to support reuse; mocking frameworks should ideally be used to create simple unit tests, but also to test external entities and to test code with minimal change. The overall perception is that the usage of mock classes is preferable over mocking frameworks, however, there are specific cases in which mocking frameworks are a better choice. Finally, we provide implications and insights to researchers and practitioners working with mock classes.Em atividades de teste, desenvolvedores frequentemente utilizam dependências que tornam os testes mais difíceis de serem implementados. Neste cenário, eles podem utilizar objetos mock para simular o comportamento de tais dependências, o que contribui para tornar os testes rápidos e isolados. Na prática, as dependências simuladas podem ser dinamicamente criadas com o apoio de frameworks de mock ou manualmente codificadas em classes mock. Enquanto frameworks de mock são bem explorados pela literatura, classes mock ainda são pouco estudadas. Avaliar classes mock pode fornecer as bases para melhor compreender como estes mocks são criados e consumidos por desenvolvedores e para detectar novas práticas e desafios. Nesta dissertação, propomos um estudo empírico e um survey para avaliar classes mock. Ao analisar projetos de software populares na linguagem Java, detectamos mais de 600 classes mock e avaliamos o seu conteúdo, projeto, evolução e utilização. Também conduzimos um survey com 39 desenvolvedores que fizeram manutenção em classes mock para melhor compreender motivações de uso. Descobrimos que classes mock: frequentemente simulam objetos de domínio, dependências externas, e serviços web; são tipicamente parte de uma hierarquia; são em sua maior parte públicas, mas 1/3 são privadas; e são largamente consumidas por projetos clientes, particularmente para apoiar testes de aplicações web. Desenvolvedores argumentam que frameworks de mock podem reduzir a qualidade do código e possuem limitações, enquanto classes mock podem melhorar a qualidade do código e são simples de se configurar em testes. Além disso, desenvolvedores declaram diversas razões sobre quando criarmos classes mock, por exemplo, para testes complexos e para apoiar o reuso; frameworks de mock deveriam, idealmente, serem utilizados para criar testes unitários simples, mas também para testar entidades externas e para testar código com mudanças mínimas. A percepção geral é que a utilização de classes mock é preferível do que os frameworks de mock, entretanto, existem casos específicos onde o uso dos frameworks de mock são uma escolha adequada. Finalmente, fornecemos implicações e observações para pesquisadores e profissionais.CNPq - Conselho Nacional de Desenvolvimento Científico e TecnológicoengUniversidade Federal de Minas GeraisPrograma de Pós-Graduação em Ciência da ComputaçãoUFMGBrasilICX - DEPARTAMENTO DE CIÊNCIA DA COMPUTAÇÃOComputação – TesesSoftware – Testes –TesesSoftware – Validação – TesesFramework (Programa de computador) – TesesSoftware engineeringSoftware testingTest doublesAssessing mock classes: an empirical studyAvaliando classes mock: um estudo empíricoinfo:eu-repo/semantics/publishedVersioninfo:eu-repo/semantics/masterThesisinfo:eu-repo/semantics/openAccessreponame:Repositório Institucional da UFMGinstname:Universidade Federal de Minas Gerais (UFMG)instacron:UFMGORIGINALDissertacaoMestradoGustavoPereira.pdfDissertacaoMestradoGustavoPereira.pdfapplication/pdf1071553https://repositorio.ufmg.br/bitstream/1843/39045/1/DissertacaoMestradoGustavoPereira.pdf32c5b8b35f9aa39c07a6eb276ebf4b9eMD51LICENSElicense.txtlicense.txttext/plain; charset=utf-82118https://repositorio.ufmg.br/bitstream/1843/39045/2/license.txtcda590c95a0b51b4d15f60c9642ca272MD521843/390452022-01-07 23:46:07.589oai:repositorio.ufmg.br:1843/39045TElDRU7Dh0EgREUgRElTVFJJQlVJw4fDg08gTsODTy1FWENMVVNJVkEgRE8gUkVQT1NJVMOTUklPIElOU1RJVFVDSU9OQUwgREEgVUZNRwoKQ29tIGEgYXByZXNlbnRhw6fDo28gZGVzdGEgbGljZW7Dp2EsIHZvY8OqIChvIGF1dG9yIChlcykgb3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UgT1VUUk8gT1JHQU5JU01PLCBWT0PDiiBERUNMQVJBIFFVRSBSRVNQRUlUT1UgVE9ET1MgRSBRVUFJU1FVRVIgRElSRUlUT1MgREUgUkVWSVPDg08gQ09NTyBUQU1Cw4lNIEFTIERFTUFJUyBPQlJJR0HDh8OVRVMgRVhJR0lEQVMgUE9SIENPTlRSQVRPIE9VIEFDT1JETy4KCk8gUmVwb3NpdMOzcmlvIEluc3RpdHVjaW9uYWwgZGEgVUZNRyBzZSBjb21wcm9tZXRlIGEgaWRlbnRpZmljYXIgY2xhcmFtZW50ZSBvIHNldSBub21lKHMpIG91IG8ocykgbm9tZXMocykgZG8ocykgZGV0ZW50b3IoZXMpIGRvcyBkaXJlaXRvcyBhdXRvcmFpcyBkYSBwdWJsaWNhw6fDo28sIGUgbsOjbyBmYXLDoSBxdWFscXVlciBhbHRlcmHDp8OjbywgYWzDqW0gZGFxdWVsYXMgY29uY2VkaWRhcyBwb3IgZXN0YSBsaWNlbsOnYS4KRepositório de PublicaçõesPUBhttps://repositorio.ufmg.br/oaiopendoar:2022-01-08T02:46:07Repositório Institucional da UFMG - Universidade Federal de Minas Gerais (UFMG)false
dc.title.pt_BR.fl_str_mv Assessing mock classes: an empirical study
dc.title.alternative.pt_BR.fl_str_mv Avaliando classes mock: um estudo empírico
title Assessing mock classes: an empirical study
spellingShingle Assessing mock classes: an empirical study
Gustavo Henrique Alves Pereira
Software engineering
Software testing
Test doubles
Computação – Teses
Software – Testes –Teses
Software – Validação – Teses
Framework (Programa de computador) – Teses
title_short Assessing mock classes: an empirical study
title_full Assessing mock classes: an empirical study
title_fullStr Assessing mock classes: an empirical study
title_full_unstemmed Assessing mock classes: an empirical study
title_sort Assessing mock classes: an empirical study
author Gustavo Henrique Alves Pereira
author_facet Gustavo Henrique Alves Pereira
author_role author
dc.contributor.advisor1.fl_str_mv André Cavalcante Hora
dc.contributor.advisor1Lattes.fl_str_mv http://lattes.cnpq.br/4957418183504876
dc.contributor.referee1.fl_str_mv Marco Túlio de Oliveira Valente
dc.contributor.referee2.fl_str_mv Bruno Barbieri de Pontes Cafeo
dc.contributor.authorLattes.fl_str_mv http://lattes.cnpq.br/1376400389578607
dc.contributor.author.fl_str_mv Gustavo Henrique Alves Pereira
contributor_str_mv André Cavalcante Hora
Marco Túlio de Oliveira Valente
Bruno Barbieri de Pontes Cafeo
dc.subject.por.fl_str_mv Software engineering
Software testing
Test doubles
topic Software engineering
Software testing
Test doubles
Computação – Teses
Software – Testes –Teses
Software – Validação – Teses
Framework (Programa de computador) – Teses
dc.subject.other.pt_BR.fl_str_mv Computação – Teses
Software – Testes –Teses
Software – Validação – Teses
Framework (Programa de computador) – Teses
description During testing activities, developers frequently rely on dependencies that make the test harder to be implemented. In this scenario, they can use mock objects to emulate the dependencies’ behavior, which contributes to make the test fast and isolated. In practice, the emulated dependency can be dynamically created with the support of mocking frameworks or manually hand-coded in mock classes. While the former is well-explored by the research literature, the latter lacks further empirical analysis. Assessing mock classes would provide the basis to better understand how those mocks are created and consumed by developers and to detect novel practices and challenges. In this dissertation, we propose an empirical and a survey study to assess mock classes. We analyze popular Java software projects, detect over 600 mock classes, and assess their content, design, evolution, and usage. We also conduct a survey with 39 developers who maintained mock classes to better understand usage motivations. We find that mock classes: often emulate domain objects, external dependencies, and web services; are typically part of a hierarchy; are mostly public (but 1/3 are private); and are largely consumed by client projects, particularly to support web testing. Developers argue that mocking frameworks may reduce code quality and have limitations, while mock classes may improve code quality and are simple to set up in tests. Moreover, developers state several reasons to create mock classes, for example, for complex testing and to support reuse; mocking frameworks should ideally be used to create simple unit tests, but also to test external entities and to test code with minimal change. The overall perception is that the usage of mock classes is preferable over mocking frameworks, however, there are specific cases in which mocking frameworks are a better choice. Finally, we provide implications and insights to researchers and practitioners working with mock classes.
publishDate 2021
dc.date.issued.fl_str_mv 2021-09-02
dc.date.accessioned.fl_str_mv 2022-01-08T02:46:07Z
dc.date.available.fl_str_mv 2022-01-08T02:46:07Z
dc.type.status.fl_str_mv info:eu-repo/semantics/publishedVersion
dc.type.driver.fl_str_mv info:eu-repo/semantics/masterThesis
format masterThesis
status_str publishedVersion
dc.identifier.uri.fl_str_mv http://hdl.handle.net/1843/39045
url http://hdl.handle.net/1843/39045
dc.language.iso.fl_str_mv eng
language eng
dc.rights.driver.fl_str_mv info:eu-repo/semantics/openAccess
eu_rights_str_mv openAccess
dc.publisher.none.fl_str_mv Universidade Federal de Minas Gerais
dc.publisher.program.fl_str_mv Programa de Pós-Graduação em Ciência da Computação
dc.publisher.initials.fl_str_mv UFMG
dc.publisher.country.fl_str_mv Brasil
dc.publisher.department.fl_str_mv ICX - DEPARTAMENTO DE CIÊNCIA DA COMPUTAÇÃO
publisher.none.fl_str_mv Universidade Federal de Minas Gerais
dc.source.none.fl_str_mv reponame:Repositório Institucional da UFMG
instname:Universidade Federal de Minas Gerais (UFMG)
instacron:UFMG
instname_str Universidade Federal de Minas Gerais (UFMG)
instacron_str UFMG
institution UFMG
reponame_str Repositório Institucional da UFMG
collection Repositório Institucional da UFMG
bitstream.url.fl_str_mv https://repositorio.ufmg.br/bitstream/1843/39045/1/DissertacaoMestradoGustavoPereira.pdf
https://repositorio.ufmg.br/bitstream/1843/39045/2/license.txt
bitstream.checksum.fl_str_mv 32c5b8b35f9aa39c07a6eb276ebf4b9e
cda590c95a0b51b4d15f60c9642ca272
bitstream.checksumAlgorithm.fl_str_mv MD5
MD5
repository.name.fl_str_mv Repositório Institucional da UFMG - Universidade Federal de Minas Gerais (UFMG)
repository.mail.fl_str_mv
_version_ 1803589296859381760