PyNose:一个Python测试脚本检测器
PyNose: A Test Smell Detector For Python
摘要:
与生产代码类似,代码气味也出现在测试代码中,它们被称为测试气味。测试气味不仅对测试代码,而且对正在测试的生产代码都有不利影响。到目前为止,大多数关于测试气味的研究都集中在程序设计语言上,比如Java和Scala。然而,没有可用的自动化工具来支持Python测试气味的识别,尽管近年来Python的流行度迅速增长。在本文中,我们努力将研究扩展到Python,建立一个工具来检测这种语言的测试气味,并在Python项目中进行测试气味的实证分析。我们首先从现有的研究中收集了一系列测试气味,并选择了可以被认为与语言无关或在Python的标准Unittest框架中具有类似功能的测试气味。我们总共确定了17种不同的测试气味。此外,我们通过挖掘频繁的代码更改模式来搜索Python特定的测试气味,这些模式可以被视为修复或引入测试气味。基于这些变化,我们提出了我们自己的测试气味,称为次优断言。为了检测所有这些测试气味,我们开发了一个名为PyNose的工具,它是PyCharm(一个流行的Python IDE)的插件。最后,我们进行了一项大规模的实证调查,旨在分析Python代码中测试气味的流行程度。我们的研究结果表明,98%的项目和84%的测试套件在研究数据集中包含至少一个测试气味。我们提出的次优断言气味在多达70.6%的项目中被检测到,使其成为列表中有价值的补充。
英文摘要:
Similarly to production code, code smells also occur in test code, where they are called test smells. Test smells have a detrimental effect not only on test code but also on the production code that is being tested. To date, the majority of the research on test smells has been focusing on programming languages such as Java and Scala. However, there are no available automated tools to support the identification of test smells for Python, despite its rapid growth in popularity in recent years. In this paper, we strive to extend the research to Python, build a tool for detecting test smells in this language, and conduct an empirical analysis of test smells in Python projects. We started by gathering a list of test smells from existing research and selecting test smells that can be considered language-agnostic or have similar functionality in Python's standard Unittest framework. In total, we identified 17 diverse test smells. Additionally, we searched for Python-specific test smells by mining frequent code change patterns that can be considered as either fixing or introducing test smells. Based on these changes, we proposed our own test smell called Suboptimal assert. To detect all these test smells, we developed a tool called PyNose in the form of a plugin to PyCharm, a popular Python IDE. Finally, we conducted a large-scale empirical investigation aimed at analyzing the prevalence of test smells in Python code. Our results show that 98% of the projects and 84% of the test suites in the studied dataset contain at least one test smell. Our proposed Suboptimal assert smell was detected in as much as 70.6% of the projects, making it a valuable addition to the list.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。