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.
翻译:与生产代码相似, 代码的气味也出现在测试代码中, 它被称为测试气味。 测试气味不仅对测试代码有害, 而且对正在测试的生产代码也有害。 到目前为止, 测试气味的大部分研究都集中在诸如 Java 和 Scala 等编程语言上。 然而, 还没有可用的自动工具支持识别 Python 的测试气味, 尽管近年来Python 的流行程度迅速增长。 在本文中, 我们努力将研究扩大到 Python 的测试气味, 建立一个工具来检测该语言的测试气味, 并且对Python 项目中的测试气味进行实证分析。 根据这些变化, 我们提议在现有的研究中收集现有测试气味清单清单清单, 并选择可被视为语言Agnorest或Python标准框架中类似功能的测试气味。 总的来说, 我们发现了17种不同的测试气味。 此外, 我们搜索了Python 特定测试气味的气味, 一种可以被视为固定或引入测试气味。 基于这些变化的气味, 我们提议在Pythimal的气味测试PyC 测试模型中, 我们建议在大规模的气质测试模型中进行一次测试性测试性测试, 我们在大规模的气态中提出了一种测试性测试性测试, 在大规模的气态中, 在大规模的气态中, 在大规模测试中, 在大规模的气态中, 最后的气态中测中测中测中, 。