@tComment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies

@tComment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies
复制标题

DOI:
10.1109/icst.2012.106
复制
发表时间:
2012-01
期刊:
2012 IEEE Fifth International Conference on Software Testing, Verification and Validation
影响因子:
--
通讯作者:
Shin Hwei Tan;D. Marinov;Lin Tan;G. Leavens
Shin Hwei Tan;D. Marinov;Lin Tan;G. Leavens
中科院分区:
其他
文献类型:
--
作者:
Shin Hwei Tan;D. Marinov;Lin Tan;G. Leavens

文献摘要

被引文献

相似文献

代码注释是软件中的重要构件。Javadoc注释在Java for API规范中广泛使用。API开发人员编写Javadoc注释,API用户阅读这些注释以理解API,例如,阅读方法的Javadoc注释,而不是阅读方法体。Javadoc注释和方法主体之间的不一致表明主体中存在错误,或者实际上是注释中存在错误,这可能会误导方法调用者在代码中引入错误。我们提出了一种新的方法,称为@TCOMMENT,用于测试Javadoc注释,特别是关于空值和相关异常的方法属性。我们的方法包括两个组成部分。第一个组件将Java项目的源文件作为输入,并自动分析Javadoc注释中的英文文本,以推断文件中方法的一组可能属性。第二个组件为这些方法生成随机测试,检查推断的属性,并报告不一致性。我们在7个开源项目中评估了@TCOMMENT,发现了29个Javadoc注释和方法体之间的不一致之处。我们报告了其中16个不一致之处,其中5个已经被开发人员确认和修复。
Code comments are important artifacts in software. Javadoc comments are widely used in Java for API specifications. API developers write Javadoc comments, and API users read these comments to understand the API, e.g., reading a Javadoc comment for a method instead of reading the method body. An inconsistency between the Javadoc comment and body for a method indicates either a fault in the body or, effectively, a fault in the comment that can mislead the method callers to introduce faults in their code. We present a novel approach, called @TCOMMENT, for testing Javadoc comments, specifically method properties about null values and related exceptions. Our approach consists of two components. The first component takes as input source files for a Java project and automatically analyzes the English text in Javadoc comments to infer a set of likely properties for a method in the files. The second component generates random tests for these methods, checks the inferred properties, and reports inconsistencies. We evaluated @TCOMMENT on seven open-source projects and found 29 inconsistencies between Javadoc comments and method bodies. We reported 16 of these inconsistencies, and 5 have already been confirmed and fixed by the developers.