arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.00169cs.SE
收藏

测试用例断言方法中消息使用和可读性的探索性研究

An Exploratory Study on the Usage and Readability of Messages Within Assertion Methods of Test Cases

Taryn Takebayashi, Anthony Peruma, Mohamed Wiem Mkaouer, Christian D. Newman

摘要:

单元测试是软件开发过程的重要组成部分,涉及开发人员编写代码来验证或断言产品代码。此外,为了帮助理解测试用例和解决问题,开发人员可以选择提供一条消息来解释断言失败的原因。在这个探索性的实证研究中,我们研究了20个开源Java系统的测试方法中包含的断言消息的特征。我们的研究结果表明,虽然开发人员很少使用提供消息的选项,但使用消息的人要么仅由字符串字面量、标识符或这两种类型的组合组成。使用标准的英语可读性测量技术,我们观察到,一个初学者的英语知识需要理解的消息只包含标识符,而四年级的教育水平需要理解的字符串文字组成的消息。我们还讨论了在断言消息构造中使用这种可读性度量技术和常见反模式的缺点。我们设想我们的结果纳入代码质量工具,评估断言消息的可理解性。

英文摘要:

Unit testing is a vital part of the software development process and involves developers writing code to verify or assert production code. Furthermore, to help comprehend the test case and troubleshoot issues, developers have the option to provide a message that explains the reason for the assertion failure. In this exploratory empirical study, we examine the characteristics of assertion messages contained in the test methods in 20 open-source Java systems. Our findings show that while developers rarely utilize the option of supplying a message, those who do, either compose it of only string literals, identifiers, or a combination of both types. Using standard English readability measuring techniques, we observe that a beginner's knowledge of English is required to understand messages containing only identifiers, while a 4th-grade education level is required to understand messages composed of string literals. We also discuss shortcomings with using such readability measuring techniques and common anti-patterns in assert message construction. We envision our results incorporated into code quality tools that appraise the understandability of assertion messages.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑