The use of asserts in code has received increasing attention in the software engineering community in the past few years, even though it has been a recognized programming construct for many decades. A previous empirical study by Casalnuovo showed that methods containing asserts had fewer defects than those that did not. In this paper, we analyze the test classes of two industrial telecom Java systems to lend support to, or refute that finding. We also analyze the physical position of asserts in methods to determine if there is a relationship between assert placement and method defect-proneness. Finally, we explore the role of test method size and the relationship it has with asserts. In terms of the previous study by Casalnuovo, we found only limited evidence to support the earlier results. We did however find that defective methods with one assert tended to be located at significantly lower levels of the class position-wise than non-defective methods. Finally, method size seemed to correlate strongly with asserts, but surprisingly less so when we excluded methods with just one assert. The work described highlights the need for more studies into this aspect of code, one which has strong links with code comprehension.
翻译:过去几年来,软件工程界日益重视使用代码中的主张,尽管这几十年来一直是公认的编程结构。Casalnuovo先前的一项经验研究表明,含有主张的方法的缺陷比没有的少。在本文件中,我们分析了两个工业电信Java系统的测试等级,以支持或反驳这一发现。我们还分析了主张的物理位置,在确定主张位置与方法易变易变性之间是否存在关系的方法中进行了分析。最后,我们探讨了测试方法规模的作用及其与主张之间的关系。在Casalnuovo的上一次研究中,我们发现支持早先结果的证据有限。然而,我们发现,有一种主张的缺陷方法往往位于等级位置低得多的等级,而不是非失效方法。最后,方法规模似乎与主张密切相关,但奇怪的是,当我们将方法与仅仅一个主张排除在外时,则不那么令人惊讶。所述工作强调需要对代码的这一方面进行更多的研究,一种与代码有很强的联系。