Use of test doubles in Android testing: an in-depth investigation

Use of test doubles in Android testing: an in-depth investigation
复制标题

Android 测试中测试替身的使用:深入调查

DOI:
10.1145/3510003.3510175
复制
发表时间:
2022
期刊:
Proceedings of the 44th IEEE and ACM SIGSOFT International Conference on Software Engineering (ICSE 2022
影响因子:
--
通讯作者:
Orso, Alessandro
Orso, Alessandro
中科院分区:
--
文献类型:
--
作者:
Fazzini, Mattia;Choi, Chase;Copia, Juan Manuel;Lee, Gabriel;Kakehi, Yoshiki;Gorla, Alessandra;Orso, Alessandro

文献摘要

相似文献

Android应用程序与其环境进行了广泛的交互,这可能会导致测试不稳定、速度慢或难以调试。开发人员经常使用双重测试来解决这些问题-开发人员定义的对象在测试执行期间替换应用程序或库类。尽管测试替身被广泛使用,但人们对它们在实践中如何使用的了解有限。为了弥合这一差距,我们提出了一项深入的实证研究,旨在阐明开发人员如何在Android应用程序中创建和使用测试替身。在我们的研究中,我们首先分析了1006个应用程序的数据集,其中包含公开可用的测试套件,以确定开发人员最常使用的框架和方法来创建测试替身。然后,我们通过研究如何创建使用这些流行框架定义的测试配对,并在数据集中定义了使用这些框架的最高数量的测试配对的十个应用程序中使用,来研究几个研究问题。我们的结果基于对2365个测试替身的分析,这些替身替换了总共784个类,为我们提供了对Android应用程序中使用的测试替身的类型以及它们的使用方式的洞察。我们的结果还表明,Android应用程序中使用的测试对和传统Java应用程序中使用的对测试对至少在某些方面有所不同。最后,我们的结果表明,测试替身可以引入测试气味,甚至会在测试代码中引入错误。在本文中,我们还讨论了我们的发现的一些启示,可以帮助这一领域的研究人员和从业者,并指导未来的研究。
Android apps interact with their environment extensively, which can result in flaky, slow, or hard-to-debug tests. Developers often address these problems using test doubles---developer-defined objects that replace app or library classes during test execution. Although test doubles are widely used, there is limited understanding of how they are used in practice. To bridge this gap, we present an in-depth empirical study that aims to shed light on how developers create and use test doubles in Android apps. In our study, we first analyze a dataset of 1,006 apps with publicly available test suites to identify which frameworks and approaches developers most commonly use to create test doubles. We then investigate several research questions by studying how test doubles defined using these popular frameworks are created and used in the ten apps in the dataset that define the highest number of test doubles using these frameworks. Our results, based on the analysis of 2,365 test doubles that replace a total of 784 classes, provide insight into the types of test doubles used within Android apps and how they are utilized. Our results also show that test doubles used in Android apps and traditional Java test doubles differ in at least some respect. Finally, our results show that test doubles can introduce test smells and even mistakes in the test code. In the paper, we also discuss some implications of our findings that can help researchers and practitioners working in this area and guide future research.