paperbot · PL 论文追踪

全部论文 待读 收藏

P2 PyNose: A Test Smell Detector For Python

PyNose:面向 Python 的测试坏味道检测器
ASE 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)2021匹配度 2/10 · 该论文是面向 Python 测试代码的测试坏味道静态检测工具与实证研究,虽与静态分析和开发者工具有一定边缘关联,但不涉及用户核心关注的 AI/LLM、Agentic 程序、浮点程序分析或贝叶斯程序分析。引用 47 inbox
Tongjie Wang, Yaroslav Golubev, Oleg Smirnov, Jiawei Li, Timofey Bryksin, Iftekhar Ahmed
crossref: 2026-09-12

AI 速览

一句话:实现 PyCharm 插件 PyNOSE,检测 Python 测试代码中的 17 种测试坏味道并开展大规模实证分析。

测试坏味道不仅损害测试代码本身,也会影响被测的生产代码质量,但已有研究多集中于 Java、Scala,Python 尚缺自动化检测工具。本文从既有文献中筛选出在 Python 标准 Unittest 框架下语言无关或功能等价的测试坏味道,共整理出 17 种;并通过挖掘与坏味道引入/修复相关的频繁代码变更模式,提出 Python 特有的 Suboptimal Assert 坏味道。作者将其实现为 PyCharm 插件 PyNOSE,并对大量 Python 项目开展大规模实证分析,发现 98% 的项目与 84% 的测试套件至少存在一种测试坏味道,而新提出的 Suboptimal Assert 出现在 70.6% 的项目中。

问题
Python 生态缺乏自动化的测试坏味道检测工具,而现有测试坏味道研究主要针对 Java、Scala 等语言。
方法
从既有研究中筛选出 17 种语言无关或在 Python Unittest 中功能等价的测试坏味道,通过挖掘频繁代码变更模式提出新坏味道 Suboptimal Assert,并实现为 PyCharm 插件 PyNOSE。
评估
在收集的 Python 项目数据集上运行 PyNOSE 进行大规模实证分析,统计各类测试坏味道在项目和测试套件中的普遍程度,并检验新提出的坏味道是否常见。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot6508,
  title = {PyNose: A Test Smell Detector For Python},
  author = {Tongjie Wang and Yaroslav Golubev and Oleg Smirnov and Jiawei Li and Timofey Bryksin and Iftekhar Ahmed},
  booktitle = {ASE},
  year = {2021},
  doi = {10.1109/ase51524.2021.9678615}
}