While a substantial body of prior research has investigated the form and nature of production code, comparatively little attention has examined characteristics of test code, and, in particular, test smells in that code. In this paper, we explore the relationship between production code properties (at the class level) and a set of test smells, in five open source systems. Specifically, we examine whether complexity properties of a production class can be used as predictors of the presence of test smells in the associated unit test. Our results, derived from the analysis of 975 production class-unit test pairs, show that the Cyclomatic Complexity (CC) and Weighted Methods per Class (WMC) of production classes are strong indicators of the presence of smells in their associated unit tests. The Lack of Cohesion of Methods in a production class (LCOM) also appears to be a good indicator of the presence of test smells. Perhaps more importantly, all three metrics appear to be good indicators of particular test smells, especially Eager Test and Duplicated Code. The Depth of the Inheritance Tree (DIT), on the other hand, was not found to be significantly related to the incidence of test smells. The results have important implications for large-scale software development, particularly in a context where organizations are increasingly using, adopting or adapting open source code as part of their development strategy and need to ensure that classes and methods are kept as simple as possible.
翻译:虽然先前的大量研究已经调查了生产编码的形式和性质,但相对而言,对测试编码特点的注意较少,特别是测试编码中的气味。在本文中,我们探讨了生产编码特性(等级一级)与5个开放源系统中的一套测试嗅觉之间的关系。具体地说,我们研究了生产分类的复杂性特性是否可以用作相关单位测试中存在测试嗅觉的预兆。我们从对975个生产级单位测试配对的分析中得出的结果表明,生产类的Cyclomatic Complicity(CC)和WMC(WMC) Weighted 方法是其相关单位测试中存在气味的有力指标。生产分类中缺乏方法的一致性似乎也很好地表明测试嗅觉的存在。也许更重要的是,所有三个指标似乎都是特定测试嗅觉,特别是Earger测试和Dubliced Code(DIT)的好指标。另一方面发现,生产分类中的Cyrence Tree(DIT)和WMC(WM)是生产类别中气味的强烈指标。在大规模测试中并没有显著的关联,因为其测试方法的发生方式是用来保证其发展,在软件的源中可以保证其开发的源。