The readability of source code is key for understanding and maintaining software systems and tests. Several studies investigate the readability of source code, but there is limited research on the readability of test code and related influence factors. We investigate the factors that influence the readability of test code from an academic perspective complemented by practical views. First, we perform a Systematic Mapping Study (SMS) with a focus on scientific literature. Second, we extend this study by reviewing grey literature sources for practical aspects on test code readability and understandability. Finally, we conduct a controlled experiment on the readability of a selected set of test cases to collect additional knowledge on influence factors discussed in practice. The result set of the SMS includes 19 primary studies from the scientific literature. The grey literature search reveals 62 sources for information on test code readability. Based on an analysis of these sources, we identified a combined set of 14 factors that influence the readability of test code. 7 of these factors were found in scientific and grey literature, while some factors were mainly discussed in academia (2) or industry (5) with limited overlap. The controlled experiment on practically relevant influence factors showed that the investigated factors have a significant impact on readability for half of the selected test cases. Our review of scientific and grey literature showed that test code readability is of interest for academia and industry with a consensus on key influence factors. However, we also found factors only discussed by practitioners. For some of these factors we were able to confirm an impact on readability in a first experiment. Therefore, we see the need to bring together academic and industry viewpoints to achieve a common view on the readability of software test code.
翻译:源代码的可读性对于理解和维护软件系统及测试至关重要。已有诸多研究探讨源代码的可读性,但针对测试代码可读性及其影响因素的研究仍较为有限。本文从学术视角出发,同时融合实践观点,系统研究影响测试代码可读性的因素。首先,我们开展了一项聚焦科学文献的系统映射研究;其次,通过审阅灰色文献,从实践层面补充测试代码可读性与易理解性的相关研究;最后,我们针对一组精选测试用例开展可控实验,以收集实践中讨论的影响因素的额外知识。系统映射研究结果包含19篇科学文献中的核心研究,灰色文献检索则揭示了62个测试代码可读性信息来源。基于对这些来源的分析,我们整合出14个影响测试代码可读性的因素。其中7个因素同时出现在科学文献与灰色文献中,而部分因素主要见于学术界(2个)或工业界(5个),且两者重叠有限。针对实践相关影响因素的可控实验表明:在半数测试用例中,所研究因素对可读性具有显著影响。通过科学文献与灰色文献的综合分析,我们发现测试代码可读性同时受到学术界与工业界的关注,且双方对关键影响因素存在共识。然而,部分因素仅由实践者讨论。对于这些因素,我们通过初步实验证实了其对可读性的影响。因此,我们认为需整合学术与工业视角,以形成对软件测试代码可读性的统一认知。